Help me please with color image processing
6 ビュー (過去 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!