I'm looking for some help with a project I'm working on.
What I'm doing is a polygon approximation algorithm. I've got all of the points of my boundary, but in order to start the algorithm, I need to find the top left and bottom right points from the set of points. All of the points are stored in a structure array that has the x and y coordinates of each point. Any ideas on an easy way to loop through the array of points?
Any help would be greatly appreciated. If you need more information, just ask and I'll provide all I can.
Top left: min(x+max(y)-y)
Bottom right: min(max(x)-x+y)
Where the inner max is a constant.
Based on your comment that bottom left is
min(x+y)
and top right ismax(x+y)
Top left:
min(x+max(y)-y)
Bottom right:
max(max(x)-x+y)
Where the inner
max
is a constant.Though this may not always give a result that agrees with your eyes.
Alternative metrics can be constructed based on the distance from the corners of the bounding box of your object, or the square of the distance, etc.
Another technique is to translate the polygon around the origin and then top left is the point furthest from the origin but in the top left quadrant... That gives a whole heap of choices as to where to put
(0,0)
could be average of all, could be weighted average based on some rule, etc. lot of variability in how you pick that, each may give results that differ for a very small number if polygons from what the eye would pick.Finally you could always train a neural network to pick the answer.... That might result in something that is (insert confidence limits from training)% likely to give an answer you agree with... But you and I may disagree