qupath icon indicating copy to clipboard operation
qupath copied to clipboard

QuPath's viewer does not support ICC profiles

Open petebankhead opened this issue 2 years ago • 2 comments

Bug report

Describe the bug QuPath's viewer doesn't (really) support ICC profiles.

This makes the display colors inconsistent with that seen in other viewers, for some file formats.

To Reproduce Steps to reproduce the behavior:

  1. Open an SVS image in QuPath
  2. Compare with the same SVS image opened in ImageScope (with ICC profile turned on)

Expected behavior QuPath would ideally provide an option to view the image with the ICC profile applied.

This should only affect the viewer; analysis itself should not be impacted.

However, it may be worth considering whether to add an ImageServer implementation that applies an ICC profile as well, since this might potentially be used as a way to do color standardisation (relevant e.g. for deep learning). If this is done, then the information must be accessible to the viewer so that any embedded ICC profile isn't applied twice.

Screenshots See https://forum.image.sc/t/color-discrepancy-qupath-x-imagescope-leica-gt450/57948

Desktop (please complete the following information):

  • OS: All
  • QuPath Version: all until v0.3.2 (current)

Additional context For further discussion, see https://forum.image.sc/t/color-discrepancy-qupath-x-imagescope-leica-gt450/57948

There is some experimental (and hidden) support for ICC profiles accessible in QuPath via scripting, e.g. see https://github.com/qupath/qupath/blob/main/qupath-gui-fx/src/main/java/qupath/lib/gui/viewer/QuPathViewer.java#L2178 However, performance is really poor and it is not really usable at this time.

Any implementation should be considered alongside gamma adjustment, see https://github.com/qupath/qupath/issues/981

petebankhead avatar Jun 01 '22 08:06 petebankhead

Looked into this and it seems a bit of a minefield with no really quick solution.

More info at https://github.com/petebankhead/ICC-Profiles

petebankhead avatar Oct 23 '22 17:10 petebankhead

New discussion at https://forum.image.sc/t/openslide-4-0-is-coming-rsn-new-features-relevant-to-qupath/86015

Here's an initial proposal for the work involved in adding preliminary support:

  • [ ] Static methods in BufferedImageTools to read ICC Profiles from TIFF images & byte arrays
  • [ ] JSON-serializable interface for a color conversion (name, type, URIs, convertTosRGB method)
    • [ ] ICC Profile implementation that is basically a wrapper handle applying an ICC Profile to convert to sRGB, caching any required ColorConvertOp
  • [ ] Retrofit ImageServer with a method to get a color conversion object (defaults to null), and return a flag to state whether the conversion has been applied when returning pixels (i.e. it's a property within the server itself - one can't ask for converted and unconverted pixels from the same server)
  • [ ] Support applying any conversion 'live' within the viewer (caching tiles as needed)
  • [ ] Support for applying any conversion at the point the image is being read via project import flags

petebankhead avatar Sep 11 '23 06:09 petebankhead