首页 > 解决方案 > 将多边形转换为另一个图像

问题描述

我正在尝试将与一个图像关联的多边形转移到另一个图像上。除了边界之外,这两个图像是相同的,我要翻译的多边形是图像上对象的标记,我将如何在此处输入图像描述翻译多边形而不旋转它?我尝试进行旋转和剪切变换以获得所需的结果:供参考的图像

for dictionary in JSONfile:
list_of_c = dictionary['pixel_coordinates']
#set scale
gp_x =35093
gp_y = 23133
sr_x= 16384
sr_y=16384
t = -215
scales=scale(gp_x,gp_y,sr_x, sr_y)
for item in list_of_c:
    x = item['x']
    y = item['y']
    #1st shear
    new_x = conversion_to_sp(slope,x,y)
    x_1 = new_x
    item['x']= new_x
    item['y']= y
    #2nd rotation

    rotated_coords =rotation_t(t,item['x'],item['y'])
    item['x'] = rotated_coords[0]
    item['y'] = rotated_coords[1]

    #scaling 
    item['x']= rotated_coords[0]*scales[0]
    item['y']= rotated_coords[1]*scales[1]
    #retrun to square hopefully
    x_update= item['x']+slope*item['y']
    item['x']= x_update+18432
    item['y']= item['y']+10240

标签: pythonimagepng

解决方案


推荐阅读