平移变换
在本章中,您将利用 Open Access Series of Imaging Studies 的数据,比较不同人群的大脑:年轻与年长、男性与女性、健康与患病。
首先,请将一个 3D 大脑体数据(im)中的单张切片居中。先找到图像数组的几何中心点,以及大脑的质心。然后,将图像平移到中心位置。
本章练习已统一导入如下库:
import imageio.v2 as imageio
import numpy as np
import scipy.ndimage as ndi
import matplotlib.pyplot as plt
本练习是课程的一部分
Python 中的生物医学图像分析
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Find image center of mass
com = ____
# Calculate amount of shift needed
d0 = 128 - _____
d1 = ____
# Translate the brain towards the center
xfm = ndi.shift(____, shift=____)