index value in RGB image
Show older comments
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?
Answers (1)
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.
12 Comments
Image Analyst
on 14 Jul 2014
Normally you would not do connected components labeling on an indexed image. It doesn't make sense. If I did that it must have been because you directly asked for it, but I would not normally do that since thresholding an indexed image is nonsense.
Hi Image Analyst, How can I refer to the value of "index". For example, if I want to change the color of a pixel based on the "index" value, how can I do it? To be clear, this is what I want to do: e.g:
for i = 1 : length(image(:,1))
for j = 1: length(image(1,:))
if "index"(i,j) == 127
image(i,j) = 1;
else
image(i,j) = 0;
end
end
end
Thanks in advance. Paul
Image Analyst
on 25 Mar 2015
Edited: Image Analyst
on 25 Mar 2015
Don't name your image "image" - that's the name of a built-in function. To do what you tried to do, you simply use logical indexing:
grayScaleImage = grayScaleImage == 127;
Don't do any of those for loops, just do the one line above. It will set all original pixels with value of 127 to 1, and any other intensity will be set to 0.
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
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
Thanks!
Sudheendran Vasudevan
on 16 May 2020
Hi Image Analyst,
I have a dead peixel in my image how to remove that
Image Analyst
on 16 May 2020
You can use a modified median filter to get rid of salt and pepper noise. I'm attaching the demo for that.
Vijaya yaduvanshi
on 4 Mar 2021
hi Image Analyst,
Im having Matlab 2015a version. In this version Nonlocal mean filter is not available for prepossessing step of my oral cancer images.Please tell me another filter of same quality.
Image Analyst
on 4 Mar 2021
I don't know. Just look around - there's medfilt2(), conv2(), imfilter(), etc.
Vijaya yaduvanshi
on 6 Mar 2021
All right.
Thank You so much
Categories
Find more on Image Arithmetic in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!