天天看點

python3讀取顯示raw檔案圖像

參考:https://scipy-lectures.org/advanced/image_processing/index.html

RAW檔案幾乎是未經過處理而直接從CCD或CMOS上得到的資訊,較jpg相比,RAW無損儲存圖像資訊。

import os
import SimpleITK as sitk
import matplotlib.pyplot as plt

if __name__=="__main__":
    #識别中文路徑名
    path="G://研究進展//example01.mhd"
    pwd = os.getcwd()
    os.chdir(os.path.dirname(path))

    #讀取切片圖像
    image = sitk.ReadImage(os.path.basename(path))
    image = sitk.GetArrayFromImage(image)

    #顯示圖像
    for i in range(1,image.shape[0],1):
        plt.figure()
        plt.imshow(image[i,:,:], cmap='gray')
        plt.pause(1)
        plt.close()
        print(i)
           

繼續閱讀