Help me please with color image processing
3 次查看(过去 30 天)
显示 更早的评论
Hello, I have two images. Img1 and Img2. All I want is to write function in MATLAB that brings each pixel from one image and compares it to each pixels of another, and then the pixels are equal then it write white color pixel on the second image. Could you please help me to write this function? Thank you.
0 个评论
回答(1 个)
Image Analyst
2015-4-3
Try this:
r1 = Img1(:,:,1);
g1 = Img1(:,:,2);
b1 = Img1(:,:,3);
r2 = Img2(:,:,1);
g2 = Img2(:,:,2);
b2 = Img2(:,:,3);
% Find pixels where each color matches.
matchingPixels = (r1 == r2) & (g1 == g2) & (b1 == b2);
imshow(matchingPixels);
% Make those pixels white in the second image's color channels:
r2(matchingPixels) = 255;
g2(matchingPixels) = 255;
b2(matchingPixels) = 255;
% Concatenate to make a full color image again
Img2 = cat(3, r2, g2, b2);
imshow(Img2);
13 个评论
Image Analyst
2015-4-8
To get rid of GUI things, just comment out any line of code that calls title(), imshow(), plot(), bar(), xlabel(), ylabel(), xlim(), ylim(), and functions like that. Once those are gone, just step through the code and if any line of code displays anything, just delete that line.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!