Code covered by the BSD License  

Highlights from
2D minimal bounding box

3.0

3.0 | 2 ratings Rate this file 39 Downloads (last 30 days) File Size: 1.95 KB File ID: #31126
image thumbnail

2D minimal bounding box

by julien diener

 

20 Apr 2011 (Updated 06 May 2011)

Compute quickly the minimal bounding box of a set of 2D points

| Watch this File

File Information
Description

Compute the minimal bounding box of a set of 2D points, similarly to the "Minimal Bounding Rectangle" of John D'Errico.

However:
 - The algorithm is fully vectorized (matlab implementation, no for loop). Thus it is better for big set of points
 - It computes only the minimum area rectangle, not the minimum perimeter

Acknowledgements
This submission has inspired the following:
Protein Array Tool
MATLAB release MATLAB 7.4 (R2007a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (4)
21 Apr 2011 John D'Errico

A nice refinement of my code, using the same ideas that made it efficient (i.e, we need only look at the edges from the convex hull) but then avoiding an explicit loop (by use of a vectorized form) over those edges. Well done by Julien.

21 Apr 2011 Sean de

Well done!

A (small) speed gain to be had if you assign:
bb(:,4) = bmax(1)*Rf(:,1) + bmin(2)*Rf(:,2);
first as to preallocate bb.

05 May 2011 Frank Fournel

Hello,
I was looking for this kind of code. Thank you very much it is very helpfull.... but it does not work well. If you remove the outlier, you should find back the rectangle. And sometime (quite often) it is not the case. I've not found yet why there is a bug. I will use the John D'Errico's code instead at the moement.

06 May 2011 julien diener

I corrected the bug (wait a few days for it to be updated on this site). Actually it is strange that it worked before...
Thanks for the remark.

John, if you want to update your file with my vectorized algorithm, I don't mind. Yours is more polished.

Please login to add a comment or rating.
Updates
06 May 2011

bug corrected

Tag Activity for this File
Tag Applied By Date/Time
area julien diener 21 Apr 2011 09:47:25
bounding box julien diener 21 Apr 2011 09:47:25
minimum julien diener 21 Apr 2011 09:47:25
computational geometry julien diener 21 Apr 2011 09:47:25
rectangle julien diener 21 Apr 2011 09:47:25

Contact us at files@mathworks.com