Improve display histogram level choice by petebankhead · Pull Request #1982 · qupath/qupath

Avoid using extremely small pyramid levels when calculating histograms for the image display.

The simple heuristic is that we choose the highest resolution that gives us an image with no more than 1024x1024 pixels - or the lowest resolution level, if no level satisfies this rule.
Previously we always chose the lowest-resolution in QuPath v0.6.0.

This addresses #1958
With the PR, the image from https://zenodo.org/records/16569043 displays sensibly.

But it also makes a difference for common OpenSlide test images OS-2.ndpi and similar.
It seems their lowest resolution level has a downsample of 4096, and dimensions of 31x18 pixels.
So histograms generated from these were terrible.
Therefore this PR helps the Brightness/Contrast dialog behave more sensibly with these images too, selecting from resolution level 8 of 13 (rather than 13).

Examples for the hematoxylin image, extracted from OS-2.ndpi using default stain vectors:

In v0.6.0
Screenshot 2025-08-22 at 16 53 51

With this PR
Screenshot 2025-08-22 at 16 54 05