3D图像旋转 Simple ITK Python

3

我正在尝试使用Simple ITK旋转3D图像。 以下是我的代码: imagetoresize 是原始图像。该图像的大小为(512,512,149)。

targetimage = imagetoresize
origin = imagetoresize.GetOrigin()
targetimage = imagetoresize
imagetoresize.SetOrigin((0,0,0))
transform = sitk.VersorTransform((0,0,1), np.pi)
transform.SetCenter((256,256,74))
outimage=sitk.Resample(imagetoresize,targetimage.GetSize(),transform,sitk.sitkLinear,[0,0,0], imagetoresize.GetSpacing(), imagetoresize.GetDirection())
outimage.SetOrigin(origin)

代码旋转了图片,但中心点发生了偏移。
原始图片 旋转后的图片 有人能解释一下为什么会出现中心点偏移吗?
非常感谢您的帮助。

你似乎假设物理点与图像的索引相同。能否请提供图像的其他元数据?如间距,起点和方向矩阵。 - blowekamp
尺寸:3 尺寸:512 512 149 矩阵: 0.832031 0 0 0 0.832031 0 0 0 1.5 偏移量:[-200.584,-382.084,-1431.5] 中心点:[0,0,0] 平移:[-200.584,-382.084,-1431.5] 反转: 1.20188 0 0 0 1.20188 0 0 0 0.666667 比例:1 1 1 原点:[-200.584,-382.084,-1431.5] 间距:[0.832031,0.832031,1.5] 均匀间隔:1 方向向量:[0,0,1] 切片数:149 - Noobie555
旋转:
维度:3 尺寸:512 512 149 矩阵: 0.832031 0 0 0 0.832031 0 0 0 1.5 偏移量:[-200.584, -382.084, -1431.5] 中心点:[0, 0, 0] 平移:[-200.584, -382.084, -1431.5] 逆矩阵: 1.20188 0 0 0 1.20188 0 0 0 0.666667 缩放:1 1 1 原点:[-200.584, -382.084, -1431.5] 间距:[0.832031, 0.832031, 1.5] 均匀间距:1 方向向量:[0, 0, 1] 切片数:149
- Noobie555
1个回答

4

您正在以像素而不是物理空间设置旋转中心。

SimpleITK(和ITK)在物理空间而非索引空间中执行变换和重采样。将图像原点设置为0应该是不必要的。我认为您应该使用imagetoresize.TransformContinuousIndexToPhysicalPoint(center_index)来获取物理空间中的中心。


谢谢你的建议!真的很有帮助。 但是我必须将原点设置为0,否则会得到一张黑色的图像。 - Noobie555

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接