[英]Find new Polygon Coordinates when I already have Old Image Size New Image Size and polygon Coordinates
I want to resize a polygon when I already have it's old coordinate as [(100,200),(200,300),(300,400),(50,60),(90,100),(400,300)] and old Image size is 1980x1080 and new image size is 640x480.当我已经将多边形的旧坐标设置为 [(100,200),(200,300),(300,400),(50,60),(90,100),(400,300)] 并且旧图像尺寸为 1980x1080 和新图像时,我想调整它的大小尺寸为 640x480。 How can I get new Coordinates of Polygon?如何获得新的多边形坐标?
Multiply the x-coordinates by 640/1980 and the y-coordinates by 480/1080.将 x 坐标乘以 640/1980,将 y 坐标乘以 480/1080。
Since you tagged numpy
:由于您标记numpy
:
import numpy as np
old_polygon = np.array([(100,200),(200,300),(300,400),(50,60),(90,100),(400,300)])
new_polygon = old_polygon * (np.array([640, 480]) / np.array([1980, 1080]))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.