MATLAB: How to read the RGB value from a grayscale image (just like the data cursor does)

dicomrgb grayscale

I have a DICOM image. I have read it and stored the value in variable 'I'. So, how to read the RGB value from a grayscale image (just like the data cursor does). Here is the image with the data cursor. Variable 'I' is consisted of the index values shown in the second line on the picture. I wonder whether we can read the RGB value by command just like the third value shown on the image. If yes, how to do it? Thanks a lot

Best Answer

cmap = colormap();
RGB = ind2rgb(YourImage, cmap);
RGB(290, 189) %notice that X is columns and Y is rows
However, if you used imshow() to display the image, then chances are that imshow decided on the colormap for you instead of using the current colormap. If so, then instead of assigning colormap() to cmap, use
cmap = gray(256);