Matlab imread grayscale import has bad contrast

1 view (last 30 days)
I'm trying to import a series of grayscale TIFF images. The pixels span the full range of values, from pure white to pure black. This can be seen when the image is viewed in a desktop program such as paint. However, when imread in Matlab is used to import the image, the contrast is greatly reduced: instead of spanning from 0 to 255 like it ought to, it covers only 70 to 95, for example. The range is different for each imported file.
The image is definitely grayscale, as imread outputs a 2D matrix.
Is there some trick that needs to be used, so that the image has the proper contrast after import?
  17 Comments
Jacob
Jacob on 14 Aug 2014
I'm just driven by curiosity now. The map is the same as what was stored under the Colormap property. 256x3 array ranging from 0 to 1. Seems to be divided into blocks of 24 rows where it would start at zero and either be all zeros for the next 24 rows; or start at zero and irregularly increase towards 1. For some reason, loading the image using imshow in the command line displays it properly without the contrast issue. I think I may still stick with csv but it's interesting that the TIFF worked in the command prompt.
Geoff Hayes
Geoff Hayes on 14 Aug 2014
Jacob - so what happens if you do the following:
[img,map] = imread('yourTifFile.tif');
imshow(img);
At this point, is the image displaying the poor contrast? If so, then do the following
colormap(map)
What does the image look like now that you are using the colour map that is associated with the image?
Maybe the integers in the 2D img matrix are NOT colours but indices into the colour map that comes with the image.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!