python - 将多边形转换为另一个图像
问题描述
我正在尝试将与一个图像关联的多边形转移到另一个图像上。除了边界之外,这两个图像是相同的,我要翻译的多边形是图像上对象的标记,我将如何在此处输入图像描述翻译多边形而不旋转它?我尝试进行旋转和剪切变换以获得所需的结果:供参考的图像
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
解决方案
推荐阅读
- c# - 如何在 Asp.Net MVC5 中使用 Ajax 将数据库更改保存到拖放列表
- r - 如何有效地基于列对数据进行子集化 (R)
- html - npm start not working for react while install react script (react script : 3.4.0 version)
- go - 扇出,多个广播,未知数量的接收器
- performance - 在 Three.js 中高效渲染数万个大小/颜色/位置可变的球体?
- javascript - 在 cytoscape.js 中使用网格布局时复合节点重叠
- swiftui - 列表与 VStack(在 ScrollView 中)
- arrays - 打字稿:错误类型错误:无法设置未定义的属性“[变量]”
- swift - 为什么我根据键盘高度调整视图的功能表现不正常?
- scheme - 关于线程的 MIT/GNU 方案参考在哪里?