Skip to content
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

Support pixelmap annotations #776

Merged
merged 5 commits into from
Feb 9, 2022
Merged

Support pixelmap annotations #776

merged 5 commits into from
Feb 9, 2022

Conversation

naglepuff
Copy link
Collaborator

This PR updates the large_image plugin to support drawing pixelmap annotations (see #767).

With `layerParams.keepLower = false`, `pixelmap` layers would disappear if the
viewer was zoomed in past the maximum level. (This is possible in HistomicsUI,
which is where this issue was observed.
@naglepuff naglepuff requested a review from manthey February 8, 2022 22:34
let pixelmapData = pixelmapElement.values;
if (pixelmapElement.boundaries) {
let valuesWithBoundaries = new Array(pixelmapData.length * 2).fill(0);
pixelmapData = valuesWithBoundaries.map((d, i) => pixelmapData[Math.floor(i / 2)]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You aren't using the values in the valuesWithBoundaries array. So fill is a wasted operation. This would probably be better as:

let valuesWithBoundaries = new Array(pixelmapData.length * 2);
for (let i = 0; i < pixelmapData.length; i += 1) {
  valuesWithBoundaries[i * 2] = valuesWithBoundaries[i * 2 + 1] = pixelmapData[i];
}

Function calls tend to be slow, so avoiding mapping something that is potentially millions long is preferred.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 89cc536

@@ -129,7 +129,6 @@ var GeojsImageViewerWidgetExtension = function (viewer) {
*/
_addPixelmapLayerParams(layerParams, pixelmapElement) {
// For pixelmap overlays, there are additional parameters to set
layerParams.keepLower = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need this set to false, since otherwise you'll get off effects if the superpixels are transparent.

I think this was fixed in OpenGeoscience/geojs@7ea4977. Are you on the master build of geojs?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

npm is telling me that I have [email protected], which looks like the latest release.

With layerParams.keepLower = false, I was seeing a problem in HisotmicsUI where zooming in past the number of levels would cause the pixelmap to disappear until zoomed out again. For example, in my testing I was working with a whole slide image with magnification 20, so HUI allows zooming in to 40x. The pixelmap layer would not be visible when zooming between 20x and 40x.

Without setting keepLower = false, I did not see that issue. I didn't see any effects (not sure what I should be looking out for though). Is there a better way to allow this kind of zooming while keeping the layer visible?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should obviously see the issue if the fill color is transparent and the stroke color is opaque. We either need to change some parameters or there is a bug in GeoJS. I'll investigate.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There will be a PR in GeoJS shortly.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see the issue now. I'll go ahead and add that line back. I'm still not sure how to deal with the issue of zooming "past" the pixelmap layer that I'm seeing in HistomicsUI.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenGeoscience/geojs#1178. I'll merge when it passes CI and then it will be available.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like that PR did the trick. I've added keepLower = false back in 65ae579

This is actually needed in the case that the pixelmap categories contain
a fully transparent fill color and opaque stroke color.
@naglepuff naglepuff requested a review from manthey February 9, 2022 18:51
@naglepuff naglepuff merged commit dd1332d into master Feb 9, 2022
@naglepuff naglepuff deleted the pixelmap-overlay-client branch February 9, 2022 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants