msalsbery / OpenSeadragonImagingHelper

MIT License
19 stars 13 forks source link

Annotation coordinates #2

Closed akazer2 closed 4 years ago

akazer2 commented 10 years ago

I'm using a custom tool to draw annotation at different zoom levels on images in OpenseaDragon. I'm trying to convert the coordinates to the pixel coordinates at maximum resolution. I can't seem to figure out how to go from the OpenseaDragon.getMousePosition() to coordinates at max resolution.

Additionally when I convert the mouse position using Physical to DataY the Y coordinate I get is occasionally negative at minimum zoom. Not sure what I'm doing wrong, or if I'm just understanding the library incorrectly. Any help would be appreciated!

msalsbery commented 10 years ago

how to go from the OpenseaDragon.getMousePosition() to coordinates at max resolution

What coordinates are you looking for (relative to what)?

when I convert the mouse position using Physical to DataY the Y coordinate I get is occasionally negative

It should only be negative if the cursor coordinate (relative to the viewer element) is above the displayed image. You can see it in action on this demo.

akazer2 commented 10 years ago

I am working with Whole Slide images. So far my team and I have full annotation capability within our software but we were hoping to use your plugin to store the annotations in logical coordinates. What I'm trying to do is convert the Mouse Position to logical coordinates and store those in my database. I guess my question is, does osd.getMousePosition() give you the same x and y as the physical coordinates? or does some kind of conversion need to be done to account for offsets of the viewer?

Thanks for the quick response. Getting these annotation overlays to work properly with zoom and pan with different shapes has been a real headache. Looking forward to AnnoHost being completed.

msalsbery commented 10 years ago

...does osd.getMousePosition() give you the same x and y as the physical coordinates? or does some kind of conversion need to be done to account for offsets of the viewer?

To account for the viewer element offset you can use OpenSeadragon.getElementOffset() (or jQuery.offset()), something like this:

    physicalPoint = osd.getMousePosition(event).minus(osd.getElementOffset(viewer.canvas));

I think I'll add a method to do this to OpenSeadragonImagingHelper...we shouldn't need to know the internals of OpenSeadragon to calculate the correct offset :)

Still working on AnnoHost port...Got sidetracked on a big change to OpenSeadragon.MouseTracker because it's broken on Windows 8+ with touch events, and just moved to new house and got my network back up. Hopefully soon, I need it too!

akazer2 commented 10 years ago

Ah yes. This is what I have been needing, the physicalPoint. Thanks. Here is the link to the project I'm currently developing, camicroscope.org. You can sign up using OpenId if you are interested in checking it out. Its a web based data management and viewing platform for pathology images. We already have fairly functional albeit buggy annotation capability. Feel free to contact us for code snippets, etc :)

Thanks again.

msalsbery commented 4 years ago

Closing this...

The new home for the OpenSeadragon Imaging plugins is here: https://github.com/openseadragon-imaging