Image 如何在MATLAB中更改边的颜色?
我有一个脚本,它将一个图像,并应用一些边缘检测方法,如canny、sobel和log。当我运行该文件时,会在边缘为白色的位置绘制一个图形 有没有办法将边的颜色更改为首选颜色Image 如何在MATLAB中更改边的颜色?,image,matlab,colors,matlab-figure,edge-detection,Image,Matlab,Colors,Matlab Figure,Edge Detection,我有一个脚本,它将一个图像,并应用一些边缘检测方法,如canny、sobel和log。当我运行该文件时,会在边缘为白色的位置绘制一个图形 有没有办法将边的颜色更改为首选颜色 function cw1 im0 = imread('lighthouse.png'); im = rgb2gray(im0); im3 = edge(im,'canny'); im4 = edge(im, 'sobel'); im5 = edge(im, 'log'); im2 = my_edge1
function cw1
im0 = imread('lighthouse.png');
im = rgb2gray(im0);
im3 = edge(im,'canny');
im4 = edge(im, 'sobel');
im5 = edge(im, 'log');
im2 = my_edge1(im);
subplot(3,2,1), subimage(im); title ('Original'); axis off
subplot(3,2,2), subimage(im2); title ('My Edge'); axis off
subplot(3,2,3), subimage(im3); title ('Canny'); axis off
subplot(3,2,4), subimage(im4); title ('Sobel'); axis off
subplot(3,2,5), subimage(im5); title ('Log'); axis off
end
这个问题不是很明确,但我还是会尽力帮助你的。下面是一个使用绿色边的演示:
function q47394633
im = rgb2gray(imread('peppers.png'));
e = edge(im); % logical matrix, where "true" indicates an edge.
g = reshape(uint8([0 255 0]),[1,1,3]) .* uint8(e); % Turn the above to RGB while making
figure(); % only the green channel nonzero.
subplot(3,1,1); imshow(e); % Show white edges
subplot(3,1,2); imshow(g); % Show green edges
subplot(3,1,3); imshow(im+g); % Show green edges on the image
end
是的,这就是我想问的。好的。如果这个答案对你有帮助,请考虑把这个问题解决。这里是代码@ @ Raja,见代码<代码> g =整形(UTI8([0 255 0 ]),[1,1,3])** UTIN 8(E);<代码>?现在代替
g
putg2…g5
,代替e
putim2…im5
,如果要绘制边缘,请使用g2…g5
,如果要在灰度图像上绘制边缘,请使用im+g2…g5
,如果要在彩色图像上绘制边缘,请使用im0+g2…g5
。关于你的代码,它应该出现在你的问题中,而不是在评论中。这次我为您添加了它(到问题中),但请确保您从一开始就添加了它。g2到g5以及im2到im5是否需要重复密切相关/重复: