フィルターのクリア

Get singular sagittal slice from nifti file saved as axial slices

7 ビュー (過去 30 日間)
Malik Ali
Malik Ali 約16時間 前
回答済み: Walter Roberson 約13時間 前
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.

回答 (1 件)

Walter Roberson
Walter Roberson 約13時間 前
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.

カテゴリ

Help Center および File ExchangeImport, Export, and Conversion についてさらに検索

製品


リリース

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by