2010-03-01 37 views
3

我不知道这是否可能,但无论如何。MATLAB将边缘区域合并回图像

我想从图像中提取边缘(我正在考虑为此使用imfilter(i,fspecial('sobel')),然后一旦边缘被提取出来,我想操作表示边缘的图像,然后一旦操作执行了重新组合与原始图像的修改的边缘图像。

这是可能的,或者沿着这些线路可能的东西吗?如果是的话可以有人提出一个方法如何执行此重组?

回答

0

回复您对史蒂夫埃丁的回答:是的,您可以。

%# make an image 
img = zeros(100); 
img(10:40,45:75)=1; 
figure,imshow(img) 

%# find the edge 
edge = bwperim(img); 

%# do something to the edge 
edge = imdilate(edge,ones(3))*0.5; 
figure,imshow(edge) 

%# replace all the pixels in the raw image that correspond to a non-zero pixel in the edge 
%# image with the values they have in the edge image 
img(edge>0) = edge(edge>0); 
figure,imshow(img) 
+0

关于此答案中的代码的一些评论:bwperim的输出是逻辑的,所以表达式(边> 0)与边相同。其次,边(边> 0)全部为1。所以作业: img(edge> 0)= edge(edge> 0); 相当于更简单的赋值: img(edge)= 1; – 2010-03-02 01:12:59

+0

其实全都是0.5。 此外,我想展示如何复制边缘像素,以防它们不均等。 – Jonas 2010-03-02 02:26:26

+0

嗨对不起,它花了一段时间,我睡着了..确定kewl我试试看,并回到你身边,但是有没有一个原因,你为什么使用bwperim,因为它不给我我想要的结果?再次感谢大家 – gagius 2010-03-02 08:32:57