MATLAB: How can i convert a polygon into a rectangle

graphicsimage processingMATLAB

I have a 4 side polygon that i draw on a video frame. I would like to take this polygon and make it a rectangle so i will be able to treat it as a matrix.I want to take the smallest rectangle i can have but still be as close as i can to the original vertices. Can anyone help me with that please? I've been trying to do it for a several days and with no success. Keep in mind that my polygon can be completely not parallel to the axes and in that case i want to get a rectangle that is also not parallel to the axes.

Best Answer

It's not trivial. But luckily John D'Errico has done it for you. See his File Exchange: http://www.mathworks.com/matlabcentral/fileexchange/34767-a-suite-of-minimal-bounding-objects
Related Question