【问题标题】:How do I apply an affine transform to a 3d numpy array?如何将仿射变换应用于 3d numpy 数组?
【发布时间】:2019-12-06 08:20:04
【问题描述】:

我使用以下代码获得了 [180,512,512] 形状的 DICOM 图像。 图像由 180 个切片组成,大小为 512x512。

dcm_list = glob.glob(os.path.join(PathDicom, "*.dcm"))
slices = [pydicom.read_file(dcm) for dcm in dcm_list]
slices.sort(key = lambda x: float(x.InstanceNumber))
if ('RescaleIntercept' in slices[0] and 'RescaleSlope' in slices[0]):
    print("TRUE")
    slope = slices[0].RescaleSlope
    intercept = slices[0].RescaleIntercept
    image = np.stack([s.pixel_array*slope+intercept for s in slices], axis=0)
else:
    image = np.stack([s.pixel_array for s in slices], axis=0)

但是,我想将这些图像倾斜成如下图所示的 4x4 仿射矩阵,但我不知道该怎么做。

4x4 affine matrix : 

[[ 2.1219860e-01  9.1372589e-03 -1.4462248e-02 -1.1527188e+02]
 [-9.1041764e-03  2.1220960e-01  1.0911685e-02 -9.0879768e+01]
 [ 3.1687310e-03 -2.1837775e-03  9.9983585e-01 -7.8977943e+01]
 [ 0.0000000e+00  0.0000000e+00  0.0000000e+00  1.0000000e+00]]

【问题讨论】:

标签: python numpy dicom affinetransform


【解决方案1】:

对于 dicom 中的 3D 功能,特别是如果您想进行旋转等,也许可以查看 simpleITK 而不是 pydicom。

它本机(并且非常快速)处理 3D dicom 图像的完整 3D 方面,并且会非常简单轻松地完成您在此处寻找的操作。

Pydicom 在很多方面都很棒,但是如果您正在寻找 3D 操作,那么您可能会更好地迁移到 SITK。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-06-06
    • 2014-04-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-20
    相关资源
    最近更新 更多