# How to perform edge detection on Color(rgb) images,so that we can get output in rgb?

I am aware of applying edge detector on rb images by first converting rgb2gray...In my work i need output of edge detector in RGB and not in grayscale....Is there any way to get output in RGB.?

• Well, yes; but: what kind of edge detector do you have in mind? There's really pretty many. And which you use kind of obviously depends on what you need to detect and what application you have. – Marcus Müller Aug 2 '17 at 21:22

Perform the edge detection channel wise and then add up the individual output.

im0 = imread(filename);
imR = im0(:,:,1);
imG = im0(:,:,2);
imB = im0(:,:,3);

res=im0;
res(:,:,1)=resR; %putting R resultant in result image
res(:,:,2)=resG; %putting  G resultant in result image
res(:,:,3)=resB; %putting B resultant in result image

imshow(res); %combined result

• Thank u for your help..i have tried this..i have applied edge detection on each channel separately…now how to combine all three outputs..i have combined these outputs using + operator…but it is not giving detected edge boundary on final output – Maria Ali Aug 3 '17 at 10:41
• In my answer resR resG resB are the output of individual outputs. I am editing answer to indicate the steps of combining invidual results. + will only add the individual intensities to each other and give a accumulate edge map! You need to asdign individual channel results to the appropriate channels in the final image! – Saikat Das Aug 3 '17 at 12:08
• Glad it helped. I dont see any specific reason to downvoting the answer without comments as it may be misleading for others. – Saikat Das Aug 3 '17 at 18:11
• what are you talking about..I did not down vote your answer..I am first time using any forum...please guide me if i did something unintentionally. – Maria Ali Aug 3 '17 at 19:12
• No, sorry I didn't mean you. Somebody else downvoted it without commenting or explaining why, which is not of much help! It's okay to downvote in case the answer is wrong or answer is unrelated. – Saikat Das Aug 3 '17 at 19:30

As suggested, do edge detection (whichever algorithm) on different channels separately, and merge then together to get back the RGB. That could be a solution.