How to read the RGB value from a grayscale image (just like the data cursor does)
Show older comments
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

Accepted Answer
More Answers (2)
Chad Greene
on 1 Mar 2017
0 votes
Alternatively, I wrote a function for this a while back. It's been a while since I wrote it, so no guarantees regarding how well it works. It's called colorpicker.
Image Analyst
on 1 Mar 2017
The function you want is called impixelinfo():
hp = impixelinfo();
set(hp, 'Units', 'normalized');
set(hp, 'Position', [.5, .9, .3, .05]); % Or whatever size and location you want.
This will put up a status label where you can see the x,y and RGB values as you mouse around over the image.
Categories
Find more on Convert Image Type in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
