How to display a monochrome color from a true color image?
이전 댓글 표시
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);
채택된 답변
추가 답변 (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
Louis Kok
2012년 5월 20일
카테고리
도움말 센터 및 File Exchange에서 Modify Image Colors에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!