matlab - How to colour the edges after using sobel filter? -


i using sobel filter edge detection. how illustrate gradient direction color coding. example, horizontal edges blue , vertical edges yellow?

thank you.

since can specify whether want horizontal or vertical edge detected (check here), perform 2 filtering operations (one horizontal , other vertical) , save each resulting image, concatenating them form final, 3-channels rgb image.

the rgb color code yellow [1 1 0] , of blue [0 0 1], in case vertical edge image occupy first 2 channels whereas horizontal edge image occupy last channel.

example:

clear clc close  = imread('circuit.tif');  [r,c,~] = size(a);  edgeh = edge(a,'sobel','horizontal'); edgev = edge(a,'sobel','vertical');  %// arrange binary images form rgb color image. finalim = zeros(r,c,3,'uint8');  finalim(:,:,1) = 255*edgev; finalim(:,:,2) = 255*edgev; finalim(:,:,3) = 255*edgeh;  figure;  subplot(1,2,1) imshow(a)  subplot(1,2,2) imshow(finalim) 

output:

enter image description here


Comments