I am displaying an intensity image of type double using imshow and casting it to uint8. In the figure property editor I changed the colormap to hsv. When the data cursor is placed on a pixel, the RGB values are revealed. How can I access these?

8 views (last 30 days)
I have an intensity image of type double called f. The intensity range is -556.1230 to + 428.1032. When I plot it using the following code:
figure;
imshow(uint8(f));
and then go to the figure property editor and change the color map to hsv. The contrast for my purposes is fantastic. Next I use the data cursor to examine pixel values. The data cursor reveals the rgb values of the pixels. The g 'channel' of the rgb color map provides nice differences in intensity levels that I am looking for. These rgb values are scaled between 0 and 1. I don't know how to get at these values that I see when using the data cursor. There is a colormap tranlation automatically occurring (because at this point I never converted the data to rgb) but I don't know how to access it?
I have tried converting the intensity image of type double to a grayscale image and then to an indexed image and then to an rgb image and then to an hsv image using the following code:
f=my double intensity image I mentioned above with pixel values between -556.1230 to + 428.1032.
g=mat2gray(f,[min(f(:)) max(f(:))]);
[h,graymap]=gray2ind(g,256);
figure;imshow(uint8(h));
r=ind2rgb(h,graymap);
figure;imshow(r)
s=rgb2hsv(r);
figure;
imshow(r);
None of these images produces the rgb pixel values between 0 & 1 as I am able to see as described above.
Thanks for any help!

Accepted Answer

Image Analyst
Image Analyst on 13 Jun 2014
I think you're reading off the colormap. There must be one applied.
Your data will be clipped to the range 0-255 when you cast it to uint8 for display. Values between -556 and 0 will be set to 0. Values greater than 255 (255 to 428) will be set to 255.
When you convert to RGB, you'll get an image with values between 0 and 255 for each color channel.
I hope that explains what's going on. But I still don't know what you want to do. Do you have any more questions?
  1 Comment
Image Analyst
Image Analyst on 13 Jun 2014
Lori's "Answer" moved here:
Thank you. That is why when I did the image type conversions I had mentioned I did not get the same values I was seeing in the Figure which automatically did the clipping.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!