How to display a monochrome color from a true color image?
6 次查看(过去 30 天)
显示 更早的评论
I have trouble displaying only the Red, Green and Blue components of my edge detection algorithm I'm using. The edges are detected for my true color RGB image, but I need to display three images representing the RED, GREEN and BLUE edge detections respectively.
I can do the edge detection for gray scale images, but the RGB one's are troublesome. Could some one please help me with this? I'm attaching my code below.
Kind regards, Louis
clear all; close all; clc;
[filename path] = uigetfile('*.*');
m=imread(filename);
figure,image(m); % Display the original picture
r=m(:,:,1); %extract the red color
g=m(:,:,2); %extract the green color
b=m(:,:,3); %extract the blue
hx =[ -1 -2 -1; 0 0 0; 1 2 1];
hy =[ -1 0 1; -2 0 2; -1 0 1];
% x dirction 'sobel' processing
xr=filter2(hx,r);
xg=filter2(hx,g);
xb=filter2(hx,b);
%combine the three color
t1(:,:,1)=xr;
t1(:,:,2)=xg;
t1(:,:,3)=xb;
size(t1)
t=uint8(t1);
figure, image(t);
% y dirction 'sobel' processing
yr=filter2(hy,r);
yg=filter2(hy,g);
yb=filter2(hy,b);
%combine the three color
t2(:,:,1)=yr;
t2(:,:,2)=yg;
t2(:,:,3)=yb;
t=uint8(t2);
figure, image(t);
%combine x and y direction processing
t3(:,:,1)=xr+yr;
t3(:,:,2)=xg+yg;
t3(:,:,3)=xb+yb;
t = uint8(t3);
figure, image(t);
0 个评论
采纳的回答
Image Analyst
2012-5-20
I thought we had this all figure out a few days ago. Didn't I give you the demo code to show r, g and b images, and Walter gave you code to cast them into the appropriate color channel to make a rue color out of the individual color channels to make them show up in "their" color? To display, you use image(), or imagesc(), or imshow(). imshow() is my preferred function. Let me know if you want to see it again.
Anyway, doing a Sobel filter on the separate color channels will give an edge image with color artifacts. You should do it on the value channel of an hsv image if you want to avoid color artifacts.
更多回答(2 个)
Louis Kok
2012-5-20
1 个评论
Image Analyst
2012-5-20
See my answer in this: http://www.mathworks.com/matlabcentral/answers/29527-criteria-of-a-good-image-testing
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Modify Image Colors 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!