How to use matlab to smooth the edge of an image

enter image description hereI get the snapshot below, but the image has very ugly edges. I want to use matlab programming to smooth the edges of the image and make it more attractive, any ideas or ways make sense?

thanks!!!

+4
source share
3 answers

Here is an option (edited):

I = im2double(imread('ht4Za.jpg'));
% Segment the object:
gs = rgb2gray(I);
Object=~im2bw(gs, graythresh(gs));

% Smoothen the mask:
BW = bwmorph(bwconvhull(Object), 'erode', 5);
Mask=repmat(BW,[1,1,3]);

% Iterate opening operation:
Interp=I;
for k=1:5
    Interp=imopen(Interp, strel('disk',20));
end

% Keep original pixels, add the newly generated ones and smooth the output:
Interpolated(:,:,1)=medfilt2(imadd(I(:,:,1).*Object, Interp(:,:,1).*~(BW==Object)), [4 4]);
Interpolated(:,:,2)=medfilt2(imadd(I(:,:,2).*Object, Interp(:,:,2).*~(BW==Object)), [4 4]);
Interpolated(:,:,3)=medfilt2(imadd(I(:,:,3).*Object, Interp(:,:,3).*~(BW==Object)), [4 4]);

% Display the results:
Masked=imadd(Interpolated.*im2double(Mask), im2double(~Mask));
imshow(Masked);

Result:

enter image description here

This is a little rude, but it will give you a start. You can try to play with the number of iterations and the size of the circular filter and the median filter. Try changing the median with an average, etc.

+5
source

imopen, RGB ( ). imopen - , , . , , 10.

img = imread('http://i.stack.imgur.com/ht4Za.jpg');
imopenBW = imopen(img, strel('disk',10));
imshow(imopenBW)
+3

You can use edge detection isocontour[1] and then the middle adjacent pixels along the path to smooth the border.

[1] http://www.mathworks.com/matlabcentral/fileexchange/30525-isocontour

0
source

All Articles