Replacing pixel value a another colour

I have a image in that suppose i want to change the pixel colour ,how i can do it.assume i have peppers image,in that if i want to replace a pixel value say 5 by yellow colour or some other colour,please tell how to proceed
please asist

Answers (1)

5 in which color channel and which color space? In general it's
rgbImage(row, column, 1) = 255;
rgbImage(row, column, 2) = 255;
rgbImage(row, column, 3) = 0;
for yellow (though I suspect you knew this already). If you have a mask (a binary image of where the 5's occur), it's somewhat different.

7 Comments

Sir its onlt colour images ,i need to clarify two more questions to complete tis work,hope you will guide me,first of all thanks for ur answer above.
I have a image say any colour image ,
I=imread('');
m=mean(I(:));finding mean
now i have to give 3 color options,RED,Yellow,(Brown or any colour);
if the value of my mean lies from 0 to 80
i need to RED COLOUR TO THAT IMAGE
IF mean value is from 80 to 150,i want to specifi the image with YELLOW
IF more than 150 i want to specify with
Brown or any colour
please assist
Seem like a weird thing to do, but you can just use the code I already gave, along with an if statement
if m < 80
rgbImage(:, :, 1) = 255;
rgbImage(:, :, 2) = 0;
rgbImage(:, :, 3) = 0;
else if m <= 150
rgbImage(:, :, 1) = 255;
rgbImage(:, :, 2) = 255;
rgbImage(row, column, 3) = 0;
else
rgbImage(:, :, 1) = 77;
rgbImage(:, :, 2) = 77;
rgbImage(:, :, 3) = 0;
end
Sir can i get anything like this
http://imgur.com/MjKvo because,the above code makes whole image in colour,cant see what is in the image
Yes, but you didn't say what the recipe was for getting that. You just took the mean of all red, all green, and all blue pixels all lumped together and then wanted the the image - the whole image presumably - to be either red, yellow, or brown based on what that mean was. That's what you asked me to do for you. If you want something different than that you need to say specifically what it is. It would be best if you made a shot at some code to explain it also.
Sir the problem is, the whole image becomes red or other color depending upon mean.i cannot see what objects are present in image.is it possible to see the objects in image after making the block any colour
Yes. Like I said, that's what you asked for. We can do something different. Recall that I said to you: " If you want something different than that you need to say specifically what it is. It would be best if you made a shot at some code to explain it also." So, how did you get that image? If you can't give code, then at least describe the method in words.
Yes i got that image that image using
my code is
rgbBlock=imread('peppers.png')
cform = makecform('srgb2lab');
lab = applycform(rgbBlock, cform);
L_channel = lab(:,:,1);
A_channel = lab(:,:,2);
B_channel = lab(:,:,3);
L_channelNew = 100 - L_channel;
A_channelNew = 255-A_channel;
labNew = cat(3, L_channelNew, A_channelNew, B_channel);
cform2 = makecform('lab2srgb');
rgbNew = applycform(labNew,cform2);
imshow(rgbNew)
i have attached a image below is it possible to give different colour for different objects
in this
i want to give different colour for fifferent objects ,say for green one colour ,brown one colour,others another colur,i tried with above code,but did not get actual result
plz assist

Sign in to comment.

Categories

Find more on Graphics Performance in Help Center and File Exchange

Tags

Asked:

FIR
on 6 Dec 2012

Community Treasure Hunt

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

Start Hunting!