0% found this document useful (0 votes)
4 views

Matlab Code GetSlice Function

This document contains code to load and process MRI scan data from multiple image slices. It loads each image slice file, saves it to a 3D array according to its slice number, and displays one of the slices after adjusting the axis scaling to account for the different pixel sizes between slices and dimensions. It loads 166 slices from files with names indicating the slice number, stores them in a 3D array according to their number, and displays slice 100 after adjusting the aspect ratio to reflect the actual size ratios of pixels between dimensions.

Uploaded by

msmtre
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Matlab Code GetSlice Function

This document contains code to load and process MRI scan data from multiple image slices. It loads each image slice file, saves it to a 3D array according to its slice number, and displays one of the slices after adjusting the axis scaling to account for the different pixel sizes between slices and dimensions. It loads 166 slices from files with names indicating the slice number, stores them in a 3D array according to their number, and displays slice 100 after adjusting the aspect ratio to reflect the actual size ratios of pixels between dimensions.

Uploaded by

msmtre
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 1

%%Exercise2.1.

mr=imread('slice100.tif');%Loadsuptheimage'slice100.tif'from
folderpath,savesimagetoMR
imagesc(mr)%imagesc='Scaledataanddisplayasimage'.
axisimage%Equalisetheaxestobeequal.
colormapgray%Mapcolourstoagreycolourpalette

%%Exercise2.1.2

mrdata=zeros(256,256,166);

forn=1:166
ifn<10%slice001.tiftoslice009.tif
mr=sprintf('slice00%d.tif',n);
elseifn<100%slice010.tiftoslice099.tif
mr=sprintf('slice0%d.tif',n);
else%slice100.tiftoslice166.tif
mr=sprintf('slice%d.tif',n);
end
disp(mr)%DisplayFilenamestobesaved
im=imread(mr);
mrdata(:,:,n)=im;
end

%%Exercise2.1.3
size(mrdata)
size(mrdata(100,:,:))%1256166
size(squeeze(mrdata(100,:,:)))%256166

%Numberscorrespondtoslices:
imagesc(squeeze(mrdata(100,:,:)))
%Theimageissquashedwidthwaysbecausetheslicesarethickerthanthe
pixelsin
%eachslice.
daspect([0.93751.21])
%e.g.[113]meansoneunitinxisequalinlengthtooneunitinyand
%threeunitsinz.

%Numberscorrespondtomm:
imagesc(1.2*(0:165),0.9375*(0:255),squeeze(mrdata(100,:,:)));
axisimage

You might also like