gagius
gagius

Reputation: 31

MATLAB combining edge region back into image

I don't know if this is possible, but here goes anyways.

I would like to extract the edges from an image (I was thinking of using imfilter(i,fspecial('sobel')) for this, then once the edges have been extracted I would like to manipulate the image representing the edges and then once the manipulation has been performed recombine the modified edge image with the original image.

Is this possible or something along these lines possible? And if so can someone suggest a way how to perform this recombination?

Upvotes: 3

Views: 1141

Answers (2)

Steve Eddins
Steve Eddins

Reputation: 1311

Try the imoverlay function on the MATLAB Central File Exchange. Here's a sample output image:

alt text
(source: mathworks.com)

Upvotes: 3

Jonas
Jonas

Reputation: 74940

In response to your comment to Steve Eddin's answer: Yes, you can.

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

Upvotes: 0

Related Questions