You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm encountering an issue with the annotation coordinates in QuPath (0.4.3), when annotations are made at different zoom levels (which cannot be avoided), the json and subsequent mask do not match with the actual annotation.
Attached is an example image with annotations:
(the actual annotation should be those deeply stained cells next the green mask)
I have tried it both in MacOS and windows system, and for different versions, though the problem can't be solved.
I've been performing annotations on histopathological images at various zoom levels. However, when I export these annotations to a JSON file, the coordinates in the JSON do not seem to match the actual positions where I made the annotations in the QuPath viewer.
def outputDirectory = new File('path')
def outputFile = new File(outputDirectory, outputFilename)
ImageIO.write(img, "PNG", outputFile)
print("Mask saved to " + outputFile.getAbsolutePath())
}
Expected Behavior:
I expect the coordinates in the JSON file to accurately reflect the positions of my annotations, regardless of the zoom level at which they were made.
Actual Behavior:
The exported JSON coordinates do not align with the actual annotated positions, especially noticeable when annotations are made at varying zoom levels.
Queries:
Is this a known issue with coordinate handling at different zoom levels in QuPath?
What are the recommended steps to ensure consistent and accurate coordinate mapping across different zoom levels?
I would appreciate any guidance or suggestions on how to resolve this issue. If additional information is needed, I am happy to provide it.
Thank you for your assistance.
Best regards,
Lily
The text was updated successfully, but these errors were encountered:
Are you sure this is an issue related to this repository ? Quickly looking at your issue, I'd recommend:
1 - to post your issue on forum.image.sc with the QuPath tag
2 - it looks like you are issue very low level graphical Java (awt, Graphics2D). I'm pretty sure it's not the correct way to add overlays in QuPath. You'd rather have to use higher level function of the QuPath API - but you'll get better answers on forum.image.sc
Hello QuPath Community,
I'm encountering an issue with the annotation coordinates in QuPath (0.4.3), when annotations are made at different zoom levels (which cannot be avoided), the json and subsequent mask do not match with the actual annotation.
Attached is an example image with annotations:
(the actual annotation should be those deeply stained cells next the green mask)
I have tried it both in MacOS and windows system, and for different versions, though the problem can't be solved.
I've been performing annotations on histopathological images at various zoom levels. However, when I export these annotations to a JSON file, the coordinates in the JSON do not seem to match the actual positions where I made the annotations in the QuPath viewer.
The code I exported json from the image are:
import qupath.lib.objects.PathObject
import qupath.lib.objects.hierarchy.PathObjectHierarchy
import qupath.lib.regions.RegionRequest
import qupath.lib.roi.ROIs
import qupath.lib.roi.interfaces.ROI
import java.awt.Color
import java.awt.Graphics2D
import java.awt.Shape
import java.awt.image.BufferedImage
import java.io.File
import javax.imageio.ImageIO
def viewer = qupath.lib.gui.QuPathGUI.getInstance().getViewer()
def server = viewer.getServer()
def hierarchy = viewer.getHierarchy()
if (!server || !hierarchy) {
print("Error: No image or hierarchy loaded.")
return
}
def scaleFactor = 0.2
def width = (server.getWidth() * scaleFactor) as int
def height = (server.getHeight() * scaleFactor) as int
def img = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_BINARY)
Graphics2D g2d = img.createGraphics()
g2d.setColor(Color.WHITE)
g2d.scale(scaleFactor, scaleFactor)
for (PathObject annotation : hierarchy.getAnnotationObjects()) {
ROI roi = annotation.getROI()
Shape shape = roi.getShape()
g2d.fill(shape)
}
g2d.dispose()
\
def originalFilename = server.getMetadata().getName()
def outputFilename = originalFilename.replaceAll('(?i)\\.[^.]+$', '.png')
//
def outputDirectory = new File('path')
def outputFile = new File(outputDirectory, outputFilename)
ImageIO.write(img, "PNG", outputFile)
print("Mask saved to " + outputFile.getAbsolutePath())
}
Expected Behavior:
I expect the coordinates in the JSON file to accurately reflect the positions of my annotations, regardless of the zoom level at which they were made.
Actual Behavior:
The exported JSON coordinates do not align with the actual annotated positions, especially noticeable when annotations are made at varying zoom levels.
Queries:
I would appreciate any guidance or suggestions on how to resolve this issue. If additional information is needed, I am happy to provide it.
Thank you for your assistance.
Best regards,
Lily
The text was updated successfully, but these errors were encountered: