朋友们好,我已经将 Canny 边缘检测应用于三个不同的图像,我得到了三个不同大小的圆圈边缘的三个图像。我想在同一个图中显示这三个不同半径的圆的边缘,但用不同的颜色来比较它们。怎么做?我尝试使用 imfused 命令,但没有得到想要的结果。请帮我
问问题
47 次
1 回答
0
这是一个快速的解决方案,但它可能不是最好的方法:
% edge detection
I = imread('circuit.tif');
bw1 = edge(I,'canny');
bw2 = edge(I,'sobel');
% black result image (it could be anything else)
imrgb = repmat(zeros(size(bw1)), [1 1 3]);
% color matrices, red and green
rm = repmat(cat(3,1,0,0),size(bw1,1),size(bw1,2));
gm = repmat(cat(3,0,1,0),size(bw1,1),size(bw1,2));
% logical matrices with same dimension as the result image
lm1 = repmat(bw1,[1 1 3]);
lm2 = repmat(bw2,[1 1 3]);
% overwrite pixel positions from the color matrices according to the logical matrices
% logical matrices were derived from the edge detected ones
imrgb(lm1) = rm(lm1);
imrgb(lm2) = gm(lm2);
imshow(imrgb)
于 2014-04-29T21:43:00.323 回答