tags:

views:

142

answers:

2

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?

+3  A: 

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

alt text

Steve Eddins
Nice thanks i think i could use this, however just to double check can any1 think of a way by which the edge region of an image can be literally be replaced by another edge image? Thanks again mr Eddins
gagius
A: 

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)
Jonas
A couple of comments about the code in this answer: The output of bwperim is logical, so the expression (edge>0) is just the same as edge. Second, edge(edge>0) is all 1s. So the assignment: img(edge>0) = edge(edge>0);is equivalent to the simpler assignment: img(edge) = 1;
Steve Eddins
Actually, it's all 0.5.Also, I wanted to show how to copy edge pixels in case they're not all equal.
Jonas
Hi sorry it took a while i was asleep.. ok kewl il try it out and get back to you, however is there a reason why you made use of bwperim because it doesnt give me the results i want? Thanks Again guys
gagius
No reason other than to produce an edge on the quick.
Jonas
Ok Thanks a lot guys
gagius
If there is an answer that solves your problem, it would be nice if you accepted it.
Jonas

related questions