RGB values in a YUV colorspace image

1 view (last 30 days)
I have an image in YUV colorspace and when i preview it using imshow() function,the image shows RGB values at each pixel but when i type img_name(x,y,:) in the workspace,it shows some other values. So how do i get those RGB values which are shown in the figure using the imshow() function in the workspace or use them for further processing.

Accepted Answer

Image Analyst
Image Analyst on 30 Jun 2015
How did you get that image in that color space? Was it from a camera?
Also, the value is different from workspace (variable editor) to what you type in because you typed in the wrong thing. You typed in img_name(x,y,:) instead of img_name(y, x, :). Remember, with matrices the ROW is the first index, not the column.
  6 Comments
nitin
nitin on 30 Jun 2015
when i convert the image in YUV space most of the pixels values img(:,:,2) and img(:,:,3) goes to zero for that particular image and in this case only,so it provides me a more convenient option to scan and manipulate the image.
Image Analyst
Image Analyst on 30 Jun 2015
That's because you have a neutral background. The S channel of an HSV image, and the A and B channels of an LAB color space image would also have very small values. I have several color classification tutorials/demos in my File Exchange: http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862 that you can adapt to get the arm.

Sign in to comment.

More Answers (2)

Thorsten
Thorsten on 30 Jun 2015
Edited: Thorsten on 30 Jun 2015
imshow treats the image as an RGB image. If it is not, e.g., if some values are negative, these values are set to 0. Note that if you click on some point in the image shown by imshow, RGB values are shown. But these are just the YUV values from your original image mapped to whatever imshow considers to be an appropriate range, (e.g., negative values are mapped to 0). To use these values for further processing would mean that you want to process the data on the peculiar scalings done by the imshow function. I doubt that this is what you want. If you need rgb values, you have to convert the YUV image to RGB.
  7 Comments
Thorsten
Thorsten on 30 Jun 2015
Please also post the original image.

Sign in to comment.


Walter Roberson
Walter Roberson on 30 Jun 2015
The others have explained why what you ask is probably not what you need. The way to do as you ask is to get the File Exchange contribution freezeColors(), apply it to the the displayed image, and then get() the CData property of the image() object.

Categories

Find more on Images 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!