Borrar filtros
Borrar filtros

Get singular sagittal slice from nifti file saved as axial slices

6 visualizaciones (últimos 30 días)
Malik Ali
Malik Ali el 26 de Jul. de 2024
Respondida: Walter Roberson el 26 de Jul. de 2024
Hello, with the following code i'm able to retrieve a single axial slice from this nifti file of a lung CT scan. I would like to know how to be able to save a slice from another view, such as sagittal or coronal in a separate image format such at png or jpg for image processing.
L1 = load_nii('lung_029.nii');
NumSlices = size(L1.img,3)
S = L1.img(:,:,125);
figure
imshow(S)
I'm using the image processing toolbox and tools for nifti and analyze image add ons.

Respuestas (1)

Walter Roberson
Walter Roberson el 26 de Jul. de 2024
Example
L1 = load_nii('lung_029.nii');
S = size(L1.img);
r1 = randi(S(1));
r2 = randi(S(2));
r3 = randi(S(3));
view1 = reshape(L1.img(r1,:,:), S(2), S(3));
view2 = reshape(L1.img(:,r2,:), S(1), S(3));
view3 = reshape(L1.img(:,:,r3), S(1), S(2));
imwrite(view1, 'view1.png');
imwrite(view2, 'view2.png');
imwrite(view3, 'view3.png');
I should note, though, that most of the time you do not need to save the extracted data into an image file in order to process it; most of the time you can just use the arrays (view1, view2, view3) directly.

Categorías

Más información sobre Biomedical Imaging en Help Center y File Exchange.

Productos


Versión

R2024a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by