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 ?
5 次查看(过去 30 天)
显示 更早的评论
x = rand([100 50]);
i = mat2gray(x);
imshow(i)
0 个评论
采纳的回答
Cam Salzberger
2016-2-29
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 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!