Created
April 18, 2022 13:10
-
-
Save upupming/bca50c875a1badf238f3aa0c9c5b56f4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# References: https://simpleitk.readthedocs.io/en/master/link_AdvancedImageReading_docs.html | |
import SimpleITK as sitk | |
import time | |
img_path = 'D:/DATA/CLD0318/patient_67.nii' | |
a = time.time() | |
X = sitk.ReadImage(img_path) | |
b = time.time() | |
print(f'sitk.ReadImage time: {b-a}') | |
file_reader = sitk.ImageFileReader() | |
file_reader.SetFileName(img_path) | |
# file_reader.ReadImageInformation() | |
# image_size = file_reader.GetSize() | |
file_reader.SetExtractIndex([0, 0, 0]) | |
file_reader.SetExtractSize([128, 128, 128]) | |
img_1 = file_reader.Execute() | |
c = time.time() | |
print(f'Only read image region takes time: {c-b}') | |
# sitk.ReadImage time: 5.593693733215332 | |
# Only read image region takes time: 0.06897830963134766 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment