View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Decimate Polygon

5.0 | 2 ratings Rate this file 16 Downloads (last 30 days) File Size: 31.3 KB File ID: #34639 Version: 1.1
image thumbnail

Decimate Polygon


Anton Semechko (view profile)


17 Jan 2012 (Updated )

Simplify a 2D closed, piecewise linear contour by specifying boundary offset tolerance.

Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

| Watch this File

File Information

Have you ever worked with 2D boundary shape representations and noticed that the same shape can be represented with reasonable accuracy by a much smaller number of points? Did you ever need to reduce the complexity of a 2D shape while retaining as many salient features as possible? If so then DecimatePoly is the function you have been looking for.

In the attached .ZIP folder you will find the primary, self-contained function titled DecimatePoly. Additionally, in the Demos folder you will find three demo files demonstrating the use of this function.

DecimatePoly_demo1: Demonstrates how to use DecimatePoly to simplify a 2D contour extracted from a binary image. Three binary images are included as examples. One of the them is shown in the screenshot. This is the only demo that requires Image Processing Toolbox to run.

DecimatePoly_demo2: Demonstrates the effectiveness of DecimatePoly in retaining sharp features.

DecimatePoly_demo3: Demonstrates how DecimatePoly can be used to improve time performance of in-polygon test at the cost of minor misclassification error.


This file inspired Mat Clust.

MATLAB release MATLAB 7.11 (R2010b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (8)
28 Jan 2013 Mattias Karlsson

Great function. It's nice that it is self contained too.

02 Aug 2012 Catarina

Hi Anton,
Your code was all I needed to solve problems in my codes due to too many useless points. Thanks a lot!

11 Jul 2012 Bjorn Gustavsson

Andrii, just out of curiosity, what would you want to get from:,-2.933803&spn=0.001457,0.002902&sll=43.267445,-2.937035&sspn=0.002914,0.005804&t=h&hq=guggenheim+museum+bilbao&z=19

Comment only
19 Jan 2012 Andrii

Andrii (view profile)

Thank you for the link.

Comment only
19 Jan 2012 Anton Semechko

Anton Semechko (view profile)

Not sure about Matlab implementation, but you can find C implementation if you follow the link provided on this page:

Comment only
19 Jan 2012 Andrii

Andrii (view profile)

It is for building extraction from aerial images. After segmentation process boundaries are zigzag-shaped with many intrusions. I would like to simplify polygons but to maintain their essential shape. It means buildings should have orthogonal angles and small extrusions should be cut off. So I am looking for some implementation algorithm in MatLab. Like this:

Comment only
19 Jan 2012 Anton Semechko

Anton Semechko (view profile)

@ Andrii, what is it you want to achieve by orthogonalizing a set of input points? Could you clarify what this operation means or perhaps provide a reference?

Comment only
19 Jan 2012 Andrii

Andrii (view profile)

Hi Anton. I have tried your function.
It works very well.
Do you know about some function like your but
which can simplify and after orthogonalize input set of points?

Comment only
23 Jan 2012 1.1

updated description

Contact us