How can i convert a polygon into a rectangle?
Ältere Kommentare anzeigen
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.
Akzeptierte Antwort
Weitere Antworten (1)
Simon
am 17 Sep. 2013
0 Stimmen
Hi!
You have your polygon coordinates in (x/y) pairs? Take their min/max values and cut from the video frame the rectangle R(xmin:xmax, ymin:ymax).
Maybe you post your code, then it's easier to help.
3 Kommentare
Maayan
am 17 Sep. 2013
Simon
am 17 Sep. 2013
Hi!
You have your variable "pos". Now you get the minimum and maximum x and y values. This are the coordinates of your rectangle, it contains all polygons.
Image Analyst
am 17 Sep. 2013
Simon is saying to use the "bounding box" of your polygon, which will have be aligned with the axes and probably larger than what I suggested. What I suggested may give a tilted rectangle but it will have a smaller size than the bounding box.
Kategorien
Mehr zu Graph and Network Algorithms finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!