MATLAB Answers

How to get smooth boundary connected image?

28 views (last 30 days)
Alex Grame
Alex Grame on 23 Jan 2019
Commented: Image Analyst on 24 Jan 2019
Hi exprts! I am trying to smooth the boundries of the binary image. I applied convex hull technique but it does not work. Can you please suggest what technique should i use to get the desired result? Your suggestion will be appreciated . Thank you so much
[Below is the required result]
[This is my effort]


Sign in to comment.

Answers (3)

KSSV on 23 Jan 2019
Edited: KSSV on 23 Jan 2019
Use boundary
I = imread('Letter_c.svg.png') ;
[nx,ny,nt] = size(I) ;
[y,x] = find(I(:,:,1)==255) ;
I1 = zeros(nx,ny) ;
[X,Y] = meshgrid(1:ny,1:nx) ;
idx = boundary(x,y) ;
idx = inpolygon(X(:),Y(:),x(idx),y(idx)) ;
I1(idx) = 255 ;


Sign in to comment.

Image Analyst
Image Analyst on 23 Jan 2019
Another way is to use sgolayfilt() or activecontour(). Demos attached.
Or you could simply blur the image and then threshold at 0.5
width = 11;
kernel = ones(width) / width^2;
blurryImage = conv2(double(binaryImage), kernel, 'same');
binaryImage = blurryImage > 0.5;

guru mahesh M
guru mahesh M on 24 Jan 2019
yes , this solution has been almost reaches the point which you desired to get.
but my suggestion will be not to use the bplot() function inside the function bodys . it will need extea memory for running .
Note : Better to use the command(argv,argc*[]) function included , so that it is very efficent code that make your design very comfortable .......

  1 Comment

Image Analyst
Image Analyst on 24 Jan 2019
guru I think you answered the wrong question. Nobody here used bplot OR a function in their Answer. And your comment about using command() doesn't seem to make sense here.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!