about image pixel information
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Walter Roberson
le 14 Nov 2012
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
Réponses (2)
Image Analyst
le 14 Nov 2012
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 commentaires
Walter Roberson
le 14 Nov 2012
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 commentaire
Image Analyst
le 14 Nov 2012
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.
Voir également
Catégories
En savoir plus sur Colormaps dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!