当前位置:网站首页>Png to NII
Png to NII
2022-06-25 20:07:00 【Orange cedar】
import SimpleITK as sitk
import glob
import numpy as np
from PIL import Image
import cv2
def save_array_as_nii_volume(data, filename, reference_name=None):
img = sitk.GetImageFromArray(data)
if (reference_name is not None):
img_ref = sitk.ReadImage(reference_name)
img.CopyInformation(img_ref)
sitk.WriteImage(img, filename)
image_path = './1/DICOM_anon/Ground/Liver'
image_arr = glob.glob(str(image_path) + str("/*"))
image_arr.sort()
print(image_arr)
# print(image_arr[0].shape)
print(len(image_arr))
allImg = []
allImg = np.zeros([len(image_arr), 256, 256], dtype='uint8')
for i in range(len(image_arr)):
single_image_name = image_arr[i]
img_as_img = Image.open(single_image_name)
# img_as_img.show()
img_as_np = np.asarray(img_as_img)
img_as_np.squeeze(2)
allImg[i, :, :] = img_as_np
# np.transpose(allImg,[2,0,1])
save_array_as_nii_volume(allImg, './S1/1.nii')
print(np.shape(allImg))
img = allImg[:, :, 55]
边栏推荐
- Jsonp non homologous interaction (click trigger)
- 2021-08-25
- Thymleaf template configuration analysis
- Database data type design (the most detailed in the whole network)
- wooyun-2014-065513
- PHP FPM, workman, spoole, golang simple performance test
- Arduino ide + esp8266+mqtt subscribe to publish temperature and humidity information
- Print 1 cute every 100 milliseconds ~ with a running lantern effect
- Does redis transaction support acid?
- 手机开户股票安全吗,买股票在哪开户?
猜你喜欢
LNMP compilation and installation
Pcl+vs2019+opencv environment configuration
New features of redis 6.0: take you 100% to master the multithreading model
<C>. Branch and loop statements
Web container basic configuration
206. reverse linked list (insert, iteration and recursion)
Panda weekly -2022/02/18
Short video is just the time. How can you quickly build your video creation ability in your app?
Wechat applet connects to the server to display mqtt data information
Now meditation: crash service and performance service help improve application quality
随机推荐
2021-08-25
PAT B1053
二、HikariCP獲取連接流程源碼分析二
Jsonp non homologous interaction (click trigger)
I Space distributor
2.3 partial sum of square and reciprocal sequences
Randomly generate 100 non repeating numbers between 1 and 150 and put them in the array
Huawei in application review test requirements
The native JS mobile phone sends SMS cases. After clicking the button, the mobile phone number verification code is sent. The button needs to be disabled and re enabled after 60 seconds
New features of redis 6.0: take you 100% to master the multithreading model
5、 Initialization analysis II of hikaricp source code analysis
JQ implements tab switching
2020-11-14-Alexnet
Jsonp processing non homologous
2.4 finding the sum of the first n terms of the interleaved sequence
Now meditation: crash service and performance service help improve application quality
2.14(Knight Moves)
Read multiple associations from a field using delimiters in laravel
PAT B1067
<C>. tic-tac-toe