File Exchange

image thumbnail

mask2poly

version 1.5.0.0 (6.18 KB) by Nikolay S.
Finds a polygon enclosing the user defined mask. Inverse of poly2mask :).

12 Downloads

Updated 25 Jul 2011

View Version History

View License

This functions goal is to find a polygon which enclosures a user supplied mask. It's a kind of a complementary of Matlab poly2mask function. The difference is that all contour points are returned- without missing points for linearly related points. In order to get a 100% complementary of poly2mask all points inside straight lines should be omitted. In my case I actually need all those points, as index of ROI.
Combining mask2poly with poly2mask the user can produce a mask from a contour (line with X and Y coordinates), and vise-versa.

Cite As

Nikolay S. (2021). mask2poly (https://www.mathworks.com/matlabcentral/fileexchange/32112-mask2poly), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (7)

ali osman selvi

Derya

pangyuteng

Nikolay S.

Hi Daniel.
Thanks for the comment. Unfortunately, it seems to be precise. Too bad I did not knew about the bwboundaries function, before writing my own. bwboundaries seems to works nicely. Out of curiosity can you send me an example of an image where my function fails (I've used it extensively in object tracking without problems)?
Thanks!

Daniel Golden

This is a great idea for a function, but it unfortunately fails in some cases. Matlab has a more robust method built in: bwboundaries.

Lili

Daniel

Thanks for that contribution. The function works fine, is minimalistic and fast! Applied with a region growing algorithm to come to a final polygon.

MATLAB Release Compatibility
Created with R2011a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!