pydicom icon indicating copy to clipboard operation
pydicom copied to clipboard

Add support for ICC color profiles

Open hackermd opened this issue 4 years ago • 7 comments

Is your feature request related to a problem? Please describe. Datasets may contain an ICC Profile to enable color reproducibility. ICC Profiles are currently not applied by pixel handlers.

Describe the solution you'd like Apply ICC Profile upon decoding of color images.

hackermd avatar Oct 31 '20 18:10 hackermd

See also #1243

hackermd avatar Oct 31 '20 18:10 hackermd

I think this should be a utility function rather than be included with the handlers

scaramallion avatar Nov 01 '20 22:11 scaramallion

That would be fine with me, too. Either way, I think it would be important that the ICC Profile is applied by default upon access of pixel_array.

hackermd avatar Nov 01 '20 22:11 hackermd

Hmm, maybe as a config option? I'm not fond of applying stuff to the pixel data without explicit instructions from users.

scaramallion avatar Nov 01 '20 22:11 scaramallion

I'm not fond of applying stuff to the pixel data without explicit instructions from users.

Decoders need to consider other attributes as well (e.g., PhotometricInterpretation and PixelPresentation), and I don't see why ICCProfile would be any different. Color reproducibility is a huge issue in microscopy imaging and I would argue that the pixel values would be simply wrong if the ICC Profile doesn't get applied.

It's unfortunate that pixel_array is a property rather than a method, otherwise one could pass arguments to it to modify the decoding behavior.

Hmm, maybe as a config option?

Not a friend of global configuration. I would prefer a function with a parameter to control the decoding behavior.

hackermd avatar Nov 01 '20 23:11 hackermd

In the meantime, we implemented color management in highdicom (https://github.com/MGHComputationalPathology/highdicom/blob/master/src/highdicom/color.py)

hackermd avatar Jul 06 '21 17:07 hackermd

@scaramallion one of the challenges in implementing this feature in pydicom has been the fact that the numpy and Pillow packages are optional dependencies. This is unfortunate, since it makes working with pixel data rather cumbersome (even using numpy.ndarray as a type hint is tricky). I have tried to work around this constraint in #1446, but would appreciate your thoughts regarding implementation.

hackermd avatar Jul 22 '21 13:07 hackermd