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
답변 (1개)
Image Analyst
2012년 12월 6일
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
FIR
2012년 12월 6일
Image Analyst
2012년 12월 6일
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
FIR
2012년 12월 6일
Image Analyst
2012년 12월 6일
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.
FIR
2012년 12월 7일
Image Analyst
2012년 12월 7일
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.
FIR
2012년 12월 8일
카테고리
도움말 센터 및 File Exchange에서 Graphics Performance에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!