No account yet ?
The NRRD (Nearly Raw Raster Data) file is a nearly raw raster data file.
It was developed to support scientific visualization and image processing applications.
Tested in Anaconda and Python 3.7
import os.path as path import sys sys.path.insert(0, path.abspath('../')) import nrrd_handler import urllib.request import matplotlib.pyplot as plt file_path = 'CT-chest.nrrd' if not path.exists(file_path): urllib.request.urlretrieve("http://www.slicer.org/w/img_auth.php/3/31/CT-chest.nrrd", file_path) nH = nrrd_handler.NrrdHandler(file_path) img_pynrrd = nH.read_by_pynrrd() img_sitk = nH.read_by_sitk() plt.imshow(img_pynrrd[:,:,0]) plt.show() plt.imshow(img_sitk[0]) plt.show()
read-nrrd2img - GitHub
Downloading and Viewing the CT-chest.nrrd File
Tested in Anaconda and Python 3.7
import numpy as np import nrrd import cv2 filename = "Guenette_FN_CISS_Subject_09.nrrd" filedata, fileheader = nrrd.read(filename) print("fileheader", fileheader) print("filedata", filedata.shape) for i in range(filedata.shape[2]): _slice = filedata[:,:,i] print(type(_slice)) print(_slice.shape) slice = (_slice.astype(np.float64)-_slice.min()) / (_slice.max()-_slice.min()) slice = slice.astype('float32') cv2.imshow("raw image", slice) cv2.waitKey(30) cv2.imwrite("slice_" + str(i).zfill(3)+ ".jpg", slice*255, [cv2.IMWRITE_JPEG_QUALITY, 100]) ''' cv2.imwrite("slice_" + str(i).zfill(3)+ ".png", slice*255) ''' cv2.destroyAllWindows
simple_nrrd_reader - GitHub
Viewing and saving images from the Guenette_FN_CISS_Subject_09.nrrd file
Welcome, my name is Eric Soupet and I am the administrator of the site elodees.com. elodees.com is a state of the art of Artificial Intelligence and aims to be collaborative, you can now offer content such as articles, events, tutorials, ... so don't hesitate !
Platform images credit : Pixabay - Pixabay License | Pexels - Pexels License