Code covered by the BSD License  

Highlights from
A suite of minimal bounding objects

4.66667

4.7 | 6 ratings Rate this file 94 Downloads (last 30 days) File Size: 268 KB File ID: #34767
image thumbnail

A suite of minimal bounding objects

by

 

25 Jan 2012 (Updated )

Suite of tools to compute minimal bounding circles, rectangles, triangles, spheres, incircles, etc.

| Watch this File

File Information
Description

I've written quite a few separate tools to generate a minimal bounding object of some ilk. So if you have a set of points in the plane, and wish to generate the minimal bounding...
- rectangle
- triangle
- general quadrilateral
- circle
- parallelogram
- semi-circle

there is a tool in here to solve your task efficiently. You will also find minboundsphere, for 3-d data. Inscribed objects are also supported, computed by incircle and insphere.

Caveat - if you have only an image, don't expect these tools to work directly. (The image processing toolbox can do much here anyway - look there first.) In order to use these tools, I require a set of extracted points.

Acknowledgements

This file inspired Polarizability Gui5.

MATLAB release MATLAB 7.5 (R2007b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (18)
30 May 2014 Anton Semechko

Hi John, I sent you an e-mail to the electronic address provided on your Matlab profile. In that e-mail I attached a point cloud for which 'minboundsphere' fails almost consistently.

28 May 2014 John D'Errico

Anton,

Please send me some cases where it fails, and I will fix it.

John

28 May 2014 Anton Semechko

Hi John, I ran your 'minboundsphere' function a number of times (for 8 different meshes) and observed that occasionally it fails to produce a minimum bounding sphere that encloses all of the points. In some of these cases, the distance for 5% of the points is a factor of 1.1 greater than the computed radius.

27 May 2014 Anton Semechko

Thanks John! Great submission. I found your function to find minimum bounding spheres especially useful.

23 May 2014 John D'Errico

Sebastien,

I can't replicate the cycle that you found with those points, but with only 7 digits printed, the numbers I used were not the same as those you used.

Regardless, I used your idea of maintaining a history that should catch any such problem. I need only keep a small subset of the active sets to catch a cycle, so there is no problem. I've posted a new version to appear tomorrow.

22 May 2014 Sebastien Roy

Nice suite, but minboundcircle can hit an infinite loop in the while section. It happens with this set:

X =

-253.0569
-253.0408
-252.0122
-251.9961

Y =

21614210
21614212
21614210
21614212

This set results in an oscillation between two wrong solutions.

Maybe the function could track the active sets already considered and jump out of the loop if a repeated state is found. Unfortunately, such solution can lead to a huge stack of past active sets.

05 May 2014 Spigge

Very useful suite John, thanks. Sometimes one would like to exclude outliers, i.e., points far out from the group of interest. If I were to include say only 90% of the total number of points in a bounding circle, what would be the best strategy you recon?

14 Oct 2013 John D'Errico

Why modify any code, a silly thing to do since it is completely unnecessary? You must first identify the points of interest. Once that is done, pass those locations into the code. All of this takes little more than a single call to find on your part.

14 Oct 2013 Tallha Akram

hi,

Code works find for the data points. How can i modify current code for image data?

18 Sep 2013 John D'Errico

minboundrect returns a polygon, so the vertices of the bounding rectangle in (x,y) coordinates, as a polygon in the standard form that matlab uses in any tool that works with a polygon (look for example at inpolygon.)

17 Sep 2013 Maayan

Hi, I'm trying to use the miniboundrect file but i don't understand how the vectors of points that i receive from the function define the minimal rectangle.

28 Feb 2013 Sven

John, just a heads-up that MATLAB 2013a pre-release doesn't like calling convhull with those short options any more...

Error using convhull
CONVHULL no longer supports or requires Qhull-specific options.
Please remove these options when calling CONVHULL.

Error in minboundrect (line 102)
edges = convhull(x,y,{'Qt'}); % 'Pp' will silence the warnings

04 Feb 2013 John D'Errico

Sorry, but I may have put a code for a bounding ellipse in there in the past, but I won't leave code in there with which I am not satisfied. This is the case of the bounding ellipse.

04 Feb 2013 Doctor61

Hi John,
Thanks for your share. I agree with Venkat, 'minboundellipse.m' would have helped me a lot with a case I have in hand.

06 Aug 2012 Ben

Hi John,

minboundellipse.m is in the demo but not in the downloaded zip file. Could you add it? Thanks!

07 Jun 2012 Carlos Martinez-Ortiz  
02 May 2012 xiuwei zhang  
01 Mar 2012 Venkat R

Dear John,

A file 'minboundellipse.m' is missing I suppose.

regards,
Venkat

Updates
26 Jan 2012

Removed a tool I had been testing, but only accidentally included

23 May 2014

Repair for minboundcircle

Contact us