How to smooth edges of polygons?
Show older comments
I created a image (uint8) with multiple filled polygons. First, I used the vision.ShapeInserter with 'Antialiasing' but this was not enough. Also insertShape + 'SmoothEdges' produced insufficient smooth edges. Are there any other ways how I can fix that?
Looking forward to your suggestions. Thanks!
Answers (2)
Andrew Chen
on 12 Oct 2017
Ex:
se = strel('disk',5);
new_img = imopen(original_image,se);
Hope this helps!
3 Comments
m975
on 13 Oct 2017
Andrew Chen
on 13 Oct 2017
Did Image Analyst's answer get you what you wanted? Otherwise, maybe you could clarify what you mean by "smooth edges". What in your mind constitutes a sufficiently smooth edge?
m975
on 13 Oct 2017
Image Analyst
on 13 Oct 2017
0 votes
You can smooth the edges with a filter. See attached.
8 Comments
m975
on 13 Oct 2017
Image Analyst
on 13 Oct 2017
I don't know how they were created and what they are. If they are images, are they grey scale, or binary? If they're binary images, you can smooth them nicely by blurring with conv2() or imfilter() and then thresholding.
Image Analyst
on 13 Oct 2017
m975's "Answer" moved here because it's not an "Answer" to the original question, but a reply to me.
I opened an image with
image = zeros(PicHeight,PicWidth,3,'uint8') + 255;
and inserted polygons with the vision.ShapeInserter. Finally, I saved the images with imwrite as PNG.
Image Analyst
on 13 Oct 2017
OK, then blurring should work, like I said. Did you try it? If not, why not?
blurredImage = imfilter(grayImage, ones(9)/81);
m975
on 13 Oct 2017
Image Analyst
on 13 Oct 2017
It looks binary, so just threshold it. The corners should then be more rounded off.
m975
on 13 Oct 2017
m975
on 19 Oct 2017
Categories
Find more on Get Started with Computer Vision Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



