Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.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
3D图像旋转简单ITK Python_Python_Image_Image Rotation_Simpleitk - Fatal编程技术网

3D图像旋转简单ITK Python

3D图像旋转简单ITK Python,python,image,image-rotation,simpleitk,Python,Image,Image Rotation,Simpleitk,我正在尝试用简单的ITK旋转3D图像。 这是我的密码: imagetoresize是原始图像。图像的大小为(512512149) 代码旋转图像,但中心移动。 有人能解释一下为什么中心会移动吗 任何帮助都将不胜感激。您正在以像素而不是物理空间设置旋转中心 SimpleTk(和ITK)在物理空间而不是索引空间中执行转换和重采样。应该没有必要将图像的原点设置为0。我认为应该使用imagetoresize.TransformContinuousIndexToPhysicalPoint(中心索引)来获取

我正在尝试用简单的ITK旋转3D图像。 这是我的密码: imagetoresize是原始图像。图像的大小为(512512149)

代码旋转图像,但中心移动。

有人能解释一下为什么中心会移动吗


任何帮助都将不胜感激。

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


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

您似乎假设物理点与图像的索引相同。你能分享你的图片的其他元数据吗?间距、原点和方向矩阵。原始:维度:3维:512 512 149矩阵:0.832031 0 0.832031 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.666667比例:1 1原点:[-200.584,-382.084,-1431.5]间距:[0.832031,0.832031,1.5]均匀间距:1方向向量:[0,0,1]切片:149旋转:标注:3维:512 512 149矩阵:0.832031 0 0.832031 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 0.666667比例:1 1原点:[-200.584,-382.084,-1431.5]间距:[0.832031,0.832031,1.5]均匀间隔:1方向向量:[0,0,1]切片:149谢谢你的建议!这真的很有帮助。但我必须将原点设置为0,否则会得到黑色图像。
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)