MATLAB Answers

index value in RGB image

90 views (last 30 days)
fereshte on 14 Jul 2014
Commented: Paul on 26 Mar 2015
hi.i have a code that use indexedImage.output image is a RGB image with index.for each pixel i have R,G,B and index value.what is index?what show index value?


Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 14 Jul 2014
The first (left most) index is the row, the middle index is the column, and the last (right most) index is the color. Specify those to get the value of a certain color channel at a certain location:
blueValue = rgbImage(row, column, 3); % Extract the blue value at this row,column location.


Show 4 older comments
Paul on 25 Mar 2015
Thanks Image Analyst. Maybe I was not clear enough. Let me use the image from fereshte (with your permission fereshte) to explain what I am trying to do (See the attached Image). We can see from this image that, we have:
  • first line ---> X: 21 Y: 42
  • 2nd line ---> Index: 148
  • 3rd line ---> RGB: 0.651, 0.651, 0.651
What I am trying to do is to change the value of each pixel with the Index = 148 in the image to 1 for example and assign 0 to all other pixel with different Index value. Please note that, when I am saying "Index", I am talking about the "Index" value in the 2nd line of the above bullets (corresponding to the Data cursor displayed in the image, in this case, Index = 148). Thanks again. Paul
Image Analyst
Image Analyst on 25 Mar 2015
OK, if it's an RGB image, then
grayScaleImage = rgbImage(:,:,2); % Extract one of the color channels.
grayScaleImage = uint8(255 * (grayScaleImage == 148));
% Make a new RGB output image
rgbOut = cat(3, grayScaleImage, grayScaleImage, grayScaleImage);
Paul on 26 Mar 2015

Sign in to comment.

Sign in to answer this question.