Compute the minimal bounding box of a set of 2D points, similarly to the "Minimal Bounding Rectangle" of John D'Errico.
- 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
julien diener (2020). 2D minimal bounding box (https://www.mathworks.com/matlabcentral/fileexchange/31126-2d-minimal-bounding-box), MATLAB Central File Exchange. Retrieved .
Worked like a charm!!
Great and Simple Code! It just does exactly what I needed.
Excellent script! Did EXACTLY what I was looking for. Thanks & Good Job!
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.
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.
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.
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.
Inspired: Protein Array Tool