簡體   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