如何在缩小的图像中找到等效点? [英] How to find an Equivalent point in a Scaled down image?

查看:49
本文介绍了如何在缩小的图像中找到等效点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在更大的图像中计算星星的角点或轮廓.为此,我将尺寸缩小到更小的尺寸 &我能清楚地得到这些点.现在如何在原始图像中映射这个点?我正在使用 opencv C++.

I would like to calculate the corner points or contours of the star in this in a Larger image. For that I'm scaling down the size to a smaller one & I'm able to get this points clearly. Now How to map this point in original image? I'm using opencv c++.

推荐答案

考虑一个简单的例子:图像大小正好减少了一半.

Consider a trivial example: the image size is reduced exactly by half.

所以,原始图像中的笛卡尔坐标(x, y)变成缩小图像中的坐标(x/2, y/2),缩小图像中的坐标(x', y')对应坐标(x*2, y*2) 在原始图像中.

So, the cartesian coordinate (x, y) in the original image becomes coordinate (x/2, y/2) in the reduced image, and coordinate (x', y') in the reduced image corresponds to coordinate (x*2, y*2) in the original image.

当然,在缩小比例的图像中,分数坐标通常会四舍五入,因此精确映射仅适用于本示例原始图像中的偶数坐标.

Of course, fractional coordinates get typically rounded off, in a reduced scale image, so the exact mapping is only possible for even-numbered coordinates in this example's original image.

概括这一点,如果图像的宽度在水平方向按 wh 垂直缩放,则坐标 (x, y) 变为坐标 (x*w, y*h),四舍五入.在我给出的例子中,w 和 h 都是 1/2,或 .5

Generalizing this, if the image's width is scaled by a factor of w horizontally and h vertically, coordinate (x, y) becomes coordinate(x*w, y*h), rounded off. In the example I gave, both w and h are 1/2, or .5

你应该能够自己算出wh的值,并且能够简单地映射坐标.当然,由于四舍五入,您将无法计算原始图像中的确切坐标.

You should be able to figure out the values of w and h yourself, and be able to map the coordinates trivially. Of course, due to rounding off, you will not be able to compute the exact coordinates in the original image.

这篇关于如何在缩小的图像中找到等效点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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