将坐标映射到调整大小的图像
我的原始图像尺寸为(969,348),调整后的图像尺寸为(696,484)。 我在调整大小的图像中有一个点(385,400),所以我想将其绘制到原始图像。 oldx = 385 oldy = 400
我使用 OpenCV C++ 调整了它的大小
resize(org, resizeimage, Size(org.rows / 0.5, org.cols / 2), 0, 0, INTER_AREA);
,我对行和列感到困惑,宽度和高度是多少。 我已经尝试过了,但它给了我 (0,484) 坐标。
Point(round(float((oldx / org.cols)) * resizeimage.cols), round(float((oldy / org.rows))) * resizeimage.rows)
I have original image of size (969,348) and the resized image is (696,484).
I have a point (385,400) in the resized image, so I want to plot it to the original image.oldx = 385 oldy = 400
I have resized it using
resize(org, resizeimage, Size(org.rows / 0.5, org.cols / 2), 0, 0, INTER_AREA);
I am using OpenCV C++ and where I am confused with the rows and cols, what is the width and height.
I have tried this but it gives me (0,484) coordinate.
Point(round(float((oldx / org.cols)) * resizeimage.cols), round(float((oldy / org.rows))) * resizeimage.rows)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
中心的距离与缩放比例(在每个轴上)成正比。
我们可以按如下方式计算
newx
和newy
:oldx
中减去x_original_center
和y_original_center
和旧
。相减后,(0, 0) 是“新中心”(应用“居中坐标系”)。
scale_x
和scale_y
缩放“零中心”坐标。插图:
准确计算中心:
C++ 转换为:
(0, 0) 是左上角,(cols-1, rows-1) 是右下角坐标。
准确的中心坐标为:
x_original_center = (original_rows-1.0)/2.0
y_original_center = (original_cols-1.0)/2.0
C++ 代码示例:
The distance for the center is proportional to the scaling (in each axis).
We may compute
newx
andnewy
as follows:x_original_center
andy_original_center
fromoldx
andoldy
.After subtraction, (0, 0) is the "new center" (applies "centered coordinate system").
scale_x
andscale_y
.x_scaled_center
andy_scaled_center
.Illustration:
Computing the center accurately:
The C++ conversion is:
(0, 0) is the top left, and (cols-1, rows-1) is the bottom right coordinate.
The accurate center coordinate is:
x_original_center = (original_rows-1.0)/2.0
y_original_center = (original_cols-1.0)/2.0
C++ code sample:
我更喜欢以下方式的地图坐标:
I prefer map coordinates in the following way: