查找左上角和右下角(C ++) [英] Finding Top Left and Bottom Right Points (C++)

查看:85
本文介绍了查找左上角和右下角(C ++)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我正在从事的项目寻求帮助.

I'm looking for some help with a project I'm working on.

我正在做的是多边形逼近算法.我已经获得了边界的所有点,但是为了启动算法,我需要从点集中找到左上和右下的点.所有点都存储在具有每个点的x和y坐标的结构数组中.有什么想法可以方便地遍历点数组吗?

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.

推荐答案

根据您的评论,左下角为min(x+y),右上角为max(x+y)

Based on your comment that bottom left is min(x+y) and top right is max(x+y)

左上:min(x+max(y)-y)

右下:max(max(x)-x+y)

内部max是常量的地方.

尽管这可能并不总是会产生与您的眼睛一致的结果.

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.

另一种技术是在原点周围平移多边形,然后左上角是离原点最远的点,但在左上象限中...这给出了放置(0,0)的位置的全部选择平均值,可以根据某些规则等进行加权平均.选择方式的差异很大,如果从眼睛中选取多边形,则每个结果可能会产生很小的差异.

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

这篇关于查找左上角和右下角(C ++)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆