about image pixel information
1 次查看(过去 30 天)
显示 更早的评论
I have a rgb level image, and I use function "rgb2gray" convert to gray level. After that I use the data cursor button to get a pix information and it shows like this: x: 65 y: 75 Index: 25 RGB: 0.0392, 0.0392, 0.0392 I find the index stand for the gray intensity , but what's the RGB value stand for and how can I get it? Thank you!
2 个评论
Walter Roberson
2012-11-14
Everyone here is asking about MATLAB Code. Please use Tags that reflect the question you are asking; see http://www.mathworks.co.uk/matlabcentral/answers/43073-a-guide-to-tags
回答(2 个)
Image Analyst
2012-11-14
The RGB value is the gray scale - note how all 3 values are the same value. I don't know the weights - you can edit rgb2gray.m to see the algorithm but the weight or the R, G, and B channels are not clear.
0 个评论
Walter Roberson
2012-11-14
When you use rgb2gray() you produce a 2D array of data from a 3D array of data. If you do not convert that 2D array back to 3D (RGB) then when you display the image, pseudocolor mapping is used, with the presented color being according to the current colormap. The default colormap would show the image in color, but you can use the colormap() command to request a grayscale colormap.
If you rgb2gray() a uint8 image, the result you get back will be uint8. The image display routine image() or the default behavior of imshow() will notice those uint8 values, and will expect that the data range is 0 to the number of entries in the current colormap. If you haven't explicitly set a colormap size along the way, then the colormap will be 64 entries. Any array entry which is larger than the number of entries in the colormap minus one, will be treated as if it was that maximum value. This (possibly clipped) value will be used to look up RGB values from the colormap. The information shown by the data cursor will have "index" equal to the actual value of the array at that location (even if it is more than the number of entries in the colormap), and the RGB values shown will be the colormap's RGB values corresponding to the (potentially clipped) index into the colormap table.
The algorithm is similar when single precision or double precision values are image()'d instead of uint8, but the range 0-1 of data values is mapped linearly into the number of entries in the colormap table, and the "index" that is displayed is the index into the colormap table. You cannot interpret the resulting index as a relative intensity without knowing the number of entries in the colormap table.
1 个评论
Image Analyst
2012-11-14
I thought he was asking what the RGB value is on the status line because he was expecting a single number because it was a grayscale, not 3 numbers like it shows. But it could be ambiguous. Perhaps he wants to do some kind of inverse look up where he hopes to get back the original RGB value, given the grayscale value reported on the status line. It would be good if it was clarified.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Colormaps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!