Why does my TIFF image appear different in MATLAB than it should?

10 views (last 30 days)
When I read pixel data from my TIFF image (called "input_image.tif") into MATLAB (e.g. by using "imread" or the "read" method of "Tiff") and display the image (e.g. by using "imshow"), the image appears too dark or discolored.
Why is this happening and what can I do to fix this?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 2 Oct 2020
It is likely that the image contains an embedded ICC profile, which affects the way in which the image should be displayed from the raw pixel data. When functions such as "imread" are executed, they only read raw pixel data from the image while ignoring any ICC profile associated with the image.
To check whether the image contains an ICC profile, you can run the following code:
info = imfinfo('input_image.tif');
hasICCProfile = isfield(info,'ICCProfileOffset')
If this is the case, then a workaround to the issue is outlined below. (Note that this workaround requires Image Processing Toolbox.)
1. First, read ICC profile data from the image file using the "iccread" function:
sourceProfile = iccread('input_image.tif');
2. Use the "makecform" function to create a color transformation structure that can convert the previous ICC profile to standard RGB:
destProfile = iccread('sRGB.icm');
ctform = makecform('icc', sourceProfile, destProfile);
3. Apply the previous transformation to the raw image pixel data using the "applycform" function to obtain the corrected pixel data, which can now be used for display.
origImage = imread('input_image.tif');
colorCorrectedImage = applycform(origImage, ctform);
imshow(colorCorrectedImage);

More Answers (0)

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!