MATLAB merges the edge region back into the image

I don’t know if this is possible, but here it’s all the same.

I would like to extract the edges from the image (I was thinking about using imfilter(i,fspecial('sobel'))for this, and then, as soon as the edges were extracted, I would like to manipulate the image representing the edges, and then after the manipulation was performed, recombine the modified edge image with the original image.

Is this possible or something like that? And if someone can suggest a way how to perform this recombination?

+3
source share
2 answers

Try using the imoverlay function on the central MATLAB file exchange. Here is an example of the output image:

alt text
(: mathworks.com)

+3

: , .

%# 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

Source: https://habr.com/ru/post/1734925/


All Articles