繁体   English   中英

3d 阵列和点云的旋转不匹配

[英]Rotation of 3d array and point cloud not matching

我有以下问题:我有一个代表一堆图像的 3d numpy 数组。 我在 3d 阵列中也有一些相关位置的点云 (n,3),我已经在其中绘制了这些位置。 我想围绕 x 轴旋转一个角度。 我执行以下操作:

#用于点云

rotation_matrix = scipy.spatial.transform.Rotation.from_euler('x', x_rot, degrees=True)
rotated_stack_points = rotation_matrix.apply(stack_points)

#for 3d 堆栈

rotated_marked_xy = scipy.ndimage.interpolation.rotate(gfp_stack, angle=-x_rot, axes=(1, 2), reshape=True)

然后我 plot 旋转 3d 数组中的旋转点云。 问题是在旋转前和旋转后绘制的点之间总是存在 xy 偏移,并且无法弄清楚原因。 这个偏移量随旋转角度而变化,它不是固定的。 任何想法为什么会发生这种情况?

如果您以不同的旋转中心旋转相同的角度,则一个 output 将与另一个相比平移。

从欧拉得到的旋转矩阵将以原点为中心进行旋转。

import scipy.spatial.transform
rotation_matrix = scipy.spatial.transform.Rotation.from_euler('x', 30, degrees=True)
rotation_matrix.apply([0,0,0])

ndimage.rotate方法围绕图像中心旋转, reshape=True将扩展边框,使角位于新框内。

import scipy.ndimage
import numpy as np
import matplotlib.pyplot as plt

x = np.ones((3, 100, 100))
xr = scipy.ndimage.rotate(x, 30, axes=(1,2))
plt.imshow(xr[0])
xr.shape
(3, 137, 137)

在此处输入图像描述

您可以通过应用translate(-c) rotate translate(+c)序列来更改旋转中心

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM