空間轉換

Python 的生醫影像分析

Stephen Bailey

Instructor

OASIS 資料庫

OASIS 標誌

Python 的生醫影像分析

差異顯著

多腦影像陣列

Python 的生醫影像分析

配準(Registration)

  • 將影像配準到範本
  • 降低空間差異

  • 範本:

    • 可代表多位受試者
    • 可能是「平均」影像
  • 需進行多種空間轉換

三影像配準

Python 的生醫影像分析

仿射轉換保留點、線與平面

轉換示例

Python 的生醫影像分析

平移(Translation)

偏移的頭部影像

import imageio.v2 as imageio
import scipy.ndimage as ndi

im=imageio.imread('OAS1036-2d.dcm')
im.shape
(256, 256)
com = ndi.center_of_mass(im)

d0 = 128 - com[0] d1 = 128 - com[1]
xfm = ndi.shift(im, shift=[d0, d1])
Python 的生醫影像分析

旋轉(Rotation)

ndi.rotate(im,
           angle=25,
           axes=(0,1))

旋轉的頭部影像

Python 的生醫影像分析

影像旋轉

xfm = ndi.rotate(im, angle=25)

xfm.shape
(297, 297)

旋轉後改變尺寸

xfm = ndi.rotate(im, angle=25, 
              reshape=False)
xfm.shape
(256, 256)

旋轉後維持尺寸

Python 的生醫影像分析

轉換矩陣

轉換矩陣:對單一影像施加以進行配準。

矩陣元素編碼不同仿射轉換的「指令」。

含四種轉換的影像

Python 的生醫影像分析

套用轉換矩陣

# 單位矩陣
mat = [[1, 0, 0],
       [0, 1, 0],
       [0, 0, 1]]

xfm = ndi.affine_transform(im, mat)

原始影像

# 平移與縮放
mat = [[0.8, 0,   -20],
       [0,   0.8, -10],
       [0,   0,   1]]
xfm = ndi.affine_transform(im,
                           mat)

轉換後影像

Python 的生醫影像分析

一起來練習吧!

Python 的生醫影像分析

Preparing Video For Download...