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

Fix black columns with downsampled images #1531

Merged
merged 5 commits into from
May 24, 2024

Conversation

petebankhead
Copy link
Member

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.

@petebankhead petebankhead requested a review from Rylern May 24, 2024 09:49
@petebankhead petebankhead added this to the v0.6.0 milestone May 24, 2024
Copy link
Contributor

@Rylern Rylern left a 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));
Copy link
Contributor

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)

Copy link
Member Author

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).

@petebankhead
Copy link
Member Author

Interesting, I have no idea why... I'll investigate

@petebankhead
Copy link
Member Author

I've added comments. The difference with export is because of the use of ImageServers.pyramidalize. There is a workaround possible by creating a rectangular ROI around the entire image first (because of this PR).

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.

@petebankhead petebankhead merged commit 1ab2942 into qupath:main May 24, 2024
3 checks passed
@petebankhead petebankhead deleted the black-lines branch May 24, 2024 17:14
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.

Black row or column appears on some downsampled images
2 participants