When i plot a grayscale image and check the value of a pixel using data cursor, it shows me the values between 0 and 1 which looks reasonable but it has a RGB scale. Can a grayscale image has RGB Values ?
7 views (last 30 days)
Show older comments
Anvinder Singh
on 25 Feb 2016
Answered: Cam Salzberger
on 29 Feb 2016
x = rand([100 50]);
i = mat2gray(x);
imshow(i)
0 Comments
Accepted Answer
Cam Salzberger
on 29 Feb 2016
Hi Anvinder,
The Data Cursor displays color values as they are displayed, rather than as the image data is stored. So for a grayscale image, or even binary image, RGB values will still be displayed, because that is how the color is actually shown. In both of those cases, though, all three of the red, green, and blue values should be the same.
This is similar to why the RGB values may differ from the index value in a grayscale image. For example:
I = 0.5*ones(100);
imshow(I)
If you put a data cursor anywhere, the index will be 0.5, but the RGB values will all be 0.502. This is because 0.502 is the closest value to that index in the colormap used for the display of the colors.
In short, RGB values are expected to be displayed. If you want to know what grayscale intensity value is being displayed in that pixel, use any of the RGB values. If you want to know what data is in the original image (fed to "imshow"), use the index value.
-Cam
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!