Why adjusting the range of an RGB image with imshow(image,[]) does not work?

Viewed 90

I have a double RGB image whose minimum value is -0.3471 and maximum value is 0.6485. I have tried to do imshow(image) and the result is the following:

enter image description here

To solve this problem, apart of summing the minimum value to the matrix of the image, I tried using imshow(image, []), which theoretically, adjusts the range of the image to the range [0,1] in this case, but if I do that, the output image is the same.

Hence, I was wondering if the problem would be caused because is a RGB image, since with gray images it does its function. In fact, I have adjusted the range of the red layer using imshow(image(:,:,1),[]).

To summarize, I would like to adjust the range of this image using imshow(if possible).

2 Answers

As you can see in the documentation for the image object, it has a CData property that can be either a 2D array (gray-scale image), or a 3D array (RGB image). In the 2D case, the values are mapped (according to the CDataMapping property) through the specified color map to obtain RGB values to show on screen. In the 3D case, the values are directly used as RGB values to show on screen.

The imshow function just creates an image object with the input matrix as the CData property. The second argument (either [] or two explicit values) specify the CLim property of the containing axes, and thereby specify the scaling of the gray-value image. But as we saw before, this setting is ignored for RGB images.

To scale the color image, simply apply a linear mapping to it before display:

a = min(image(:));
b = max(image(:));
imshow((image-a)/(b-a))

Cris' answer below is accurate, I was mistaken in my original post. I've removed that content even though it was accepted in favor of Chris' post.

Related