-
Notifications
You must be signed in to change notification settings - Fork 272
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
Fix black columns with downsampled images #1531
Conversation
Attempt to fix qupath#1527 Spoiler: didn't work. But *possibly* improves robustness slightly anyway.
Potentially better fix for qupath#1527
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.
Running the Liverquant tissue detection works well with this PR. However, when I click on File, Export images..., Original pixels, JPEG (or PNG) and downsample of 32 with the GTEX-12584-1526 image, I still get the black column, do you know why?
maxY = Math.max(maxY, tile.getRegionRequest().getMaxY()); | ||
} | ||
if (maxX < request.getMaxX() || maxY < request.getMaxY()) { | ||
int width2 = (int)Math.max(1, Math.round((maxX - request.getMinX()) / request.getDownsample() - 1e-9)); |
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.
Maybe a small comment explaining the - 1e-9
would be useful (it's not immediately obvious)
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.
Good point, I'll add one. It's because it appears x.5 needs to be rounded down, not up (at least for the troublesome image).
Interesting, I have no idea why... I'll investigate |
I've added comments. The difference with export is because of the use of It's not optimal, but I think we can leave it at the comment - we might move away from this image export before it becomes a significant enough problem to warrant more time. |
Attempts to fix #1527
This tries to take a conservative approach that should fix the most common occurrence of this: basically, if a request is made for to get the 'last' pixels on the right or bottom of the image, then a check is made to see if this can be fulfilled using the available lower resolution tiles.
If the tiles don't quite make it (due to the lower pyramid levels being truncated), then a slightly smaller image can be returned - typically missing the last row and/or column.
The unfortunate consequence would be that we can't compute the returned image size based upon the
RegionRequest
(width, height and downsample) - because this might have been internally adjusted. To handle that, we resize then to fit expectations.It feels messy and suboptimal, but failing to do this can result in black rows or columns appearing - which can thwart thresholds and image statistics and certain resolutions, and this is more problematic.