本文介绍了如何在MATLAB中改变边缘的颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个脚本,它将图像带到并应用一些边缘检测方法,如canny,sobel和log。当我运行文件时,会绘制一个边缘为白色的图形。
I have a script which takes an image to and applies some edge detection methods such as canny, sobel and log to it. When I run the file, a figure is drawn where the edges are white.
有没有办法将边缘的颜色更改为首选颜色?
Is there a way to change the color of the edges to a preferred color?
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
推荐答案
问题不在确切定义明确,但无论如何我都会尽力帮助。这是使用绿色边缘的演示:
The question is not exactly well-defined, but I'll try to help anyway. Here's a demonstration using green edges:
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
这篇关于如何在MATLAB中改变边缘的颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!