-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Display image overlay annotations #750
Conversation
You'll probably need to merge or rebase on master for CI to have any chance of passing since Pillow 9.0.0 broke some of the tests. |
Also, get rid of some code that will not be used in convertFeatures.js.
504e682
to
e1ec9de
Compare
(WIP) Fix test overlay element JSON (WIP) Fix creating test overlay annovation (WIP) Move test overlay to setup section Fix test for drawing overlay annotations
e1ec9de
to
a20f3ce
Compare
@@ -1,3 +1,5 @@ | |||
// import { restRequest } from '@girder/core/rest'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed in 5b3f52b
girder_annotation/girder_large_image_annotation/web_client/views/imageViewerWidget/geojs.js
Outdated
Show resolved
Hide resolved
girder_annotation/girder_large_image_annotation/web_client/views/imageViewerWidget/geojs.js
Show resolved
Hide resolved
girder_annotation/girder_large_image_annotation/web_client/views/imageViewerWidget/geojs.js
Outdated
Show resolved
Hide resolved
Also remove commented out import.
New property `_unclampBoundsForOverlay` with getter/setter added to control whether or not the X/Y bounds should be clamped when rendering image overlays. Unclamping the bounds is useful because image overlays may be cut off by the viewer if they are larger than the base image layer. However, unclamped bounds eliminates the scroll out to center functionality. The default behavior at the time of this commit is to unclamp the bounds.
girder_annotation/girder_large_image_annotation/web_client/views/imageViewerWidget/geojs.js
Outdated
Show resolved
Hide resolved
I see two issues. I placed a small image (one using the PIL tile source) as an overlay on a much larger image with an identity matrix specified as the transform. Internally, I still see transform parameters being applied ( More importantly, though, the small image is magnified. Fundamentally, the scale is incorrect, since the function that calculates the layer properties is making level 0 tiles appear at the same scale for the two sources. This might be as simple as scaling down the transform matrix based on the number of tile levels between the two images, but it might be more complex than that. |
Remove console log statement
This is easy enough to fix. The issue lies with the check
I think I see this as well. If I overlay a small image (~4k by 2k) onto a very large image (~90k by 90k), the small image is blown up well beyond the space it should take up. With my test images, the smaller has 6 zoom levels, the large has 10. How does this ratio inform how to appropriately scale the smaller image? |
GeoJS has a utility function ( Alternately, we can probably twiddle the affine transform to make up for the fact that this isn't so -- by scaling the image by 2**(maxlevel of base image - maxlevel of overlayimage) to account for the number of tile levels difference and by (tile width of base image / tile width of overlay image), (tile height of base image / tile height of overlay image). This will probably just work, but the extending or adjusting the results from pixelCoordinateParams would be "more correct" and probably by slightly more efficient. I'll see if I can generalize this, as we've wanted it once before on a different project. |
Which parameter outputs would need to be adjusted?
I've been fiddling around with this and it seems to be a decent workaround. However, I'd prefer to do something more "correct." I'm leaning towards adjusting the output of |
So I dug through an old example I had where I did this somewhere else. There is code below.
|
Refactor generating layer params for overlay Fix layer params with different zoom levels
girder_annotation/girder_large_image_annotation/web_client/views/imageViewerWidget/geojs.js
Outdated
Show resolved
Hide resolved
params.layer.opacity = overlay.opacity || 1; | ||
|
||
if (this.levels !== overlayImageMetadata.levels) { | ||
const levelDifference = Math.abs(this.levels - overlayImageMetadata.levels); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should NOT be abs
-- it could be negative.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in a1743d5
_generateOverlayLayerParams(overlayImageMetadata, overlayImageId, overlay) { | ||
const geo = window.geo; | ||
let params = geo.util.pixelCoordinateParams( | ||
this.viewer.node(), overlayImageMetadata.sizeX, overlayImageMetadata.sizeY, overlayImageMetadata.tileHeight, overlayImageMetadata.tileWidth |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tileWidth and tileHeight are swapped in this call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in a1743d5
Don't use absolute value when determining the difference in levels between the base image and overlay image. Swap tileWidth and tileHeight in call to `pixelCoordinateParams`, as they were out of order.
Implement client support for image overlay annotation elements.
Changes include:
large_image
UI(opening as draft PR to kick start discussion about implementation details)
Closes #678