Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/292.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何将非矩形网格拟合到x和y坐标的样本?_Python_Image Processing_Interpolation - Fatal编程技术网

Python 如何将非矩形网格拟合到x和y坐标的样本?

Python 如何将非矩形网格拟合到x和y坐标的样本?,python,image-processing,interpolation,Python,Image Processing,Interpolation,我想做一个查找表,用于解扭曲投影到圆顶内部的给定图像。这个装置看起来有点像,但(对于老鼠来说)更小。我收集了一组点,这些点定义了圆顶内部均匀分布点的低分辨率网格 以下是坐标: [(744498), (721, 526), (686, 541), (649, 543), (598, 537), (561, 519), (546, 495), (479, 541), (436, 600), (442, 654), (500, 682), (577, 701), (639, 708), (694, 7

我想做一个查找表,用于解扭曲投影到圆顶内部的给定图像。这个装置看起来有点像,但(对于老鼠来说)更小。我收集了一组点,这些点定义了圆顶内部均匀分布点的低分辨率网格

以下是坐标:

[(744498), (721, 526), (686, 541), (649, 543), (598, 537), (561, 519), (546, 495), (479, 541), (436, 600), (442, 654), (500, 682), (577, 701), (639, 708), (694, 707), (786, 684), (844, 659), (854, 596), (813, 538), (520, 566), (485, 627), (582, 589), (569, 652), (644, 593), (643, 659), (702, 591), (711, 653), (750, 569), (774633)]

以下是网格的外观:

我想创建一个与实际显示(720x1280)大小相同的网格,以适合我收集的坐标。有没有一种方法可以将非矩形网格“适配”到这样的一组点上,如果有,如何用Python实现这种方法

编辑:

多亏了@bogovicj,我才能够解决这个问题(我想)。解决方案如下

# image transformation
from skimage import transform as tf
src = <x and y coordinates from source grid>
dst = <x and y coordinates from the destination grid>
tform =tf.estimate_transform(ttype='piecewise-affine', src=src, dst=dst)
base_image = <some image of the shape 720 rows by 1280 columns>
warped_image = tf.warp(base_image, inverse_map=tform.inverse)

# plot the results
from matplotlib import pylab as plt
fig, (ax1, ax2) = plt.subplots(ncols=2)
ax1.imshow(base_image, cmap='gray')
ax1.scatter(src[:,0], src[:,1], color='r', marker='+', s=100)
ax2.imshow(warped_image, cmap='gray')
ax2.scatter(dst[:,0], dst[:,1], color='r', marker='+', s=100)
图像变换 从skipage导入转换为tf src= dst= tform=tf.estimate_变换(ttype='pieclewise-affine',src=src,dst=dst) 基本图像= 扭曲的图像=tf.warp(基础图像,反向映射=tform.reverse) #绘制结果 从matplotlib导入pylab作为plt 图(ax1,ax2)=plt.子批次(ncols=2) ax1.imshow(基本图像,cmap='gray') ax1.scatter(src[:,0],src[:,1],color='r',marker='+',s=100) ax2.imshow(扭曲的_图像,cmap='gray') ax2.散点(dst[:,0],dst[:,1],color='r',marker='+',s=100)


变换估计在处理目标网格顶部的凹度时似乎有点困难,但除此之外,它看起来很棒,并且可能会随着更高分辨率的源/目标网格而改善。

@您的问题似乎是“如何解决径向失真问题”,使用深度学习可以找到一个实用的解决方案。您是否希望将区域边界映射到矩形图像的边界?七个点的四个“弧”应该映射到平行的水平线?这可能会有所帮助:@bogovicj,是的,这正是我想要做的(很抱歉,这个问题不清楚)。这看起来很有希望。这种方法看起来很有希望。我明天会尝试一下,如果成功的话,我会编辑我的帖子,加入解决方案。太好了!是的,我希望分段仿射能表现得更好。Scipy还有一些scikit图像没有的插值选项,可以试试这些吗?也许三次样条曲线或薄板样条曲线会更好?