different matrix size after 3D interpolation
13 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I was trying to resample my SPECT and CT images. SPECT is 128*128*102 image and CT is 512*512*263. Following is the code I wrote :
% Resample SPECT images:
[SPECT, map] = dicomread('abc.IMA');
SPECTinfo = dicominfo('abc.IMA');
SPECT = squeeze(double(SPECT));
[rows, columns, slices] = size(SPECT);
SPECTPixelSpacing = SPECTinfo.PixelSpacing;
SPECTSliceThickness = SPECTinfo.SliceThickness;
% define original SPECT meshgrid
[Xold, Yold, Zold] = meshgrid(SPECTPixelSpacing(2)*[0:1:size(SPECT, 2)-1],...
SPECTPixelSpacing(1)*[0:1:size(SPECT, 1)-1],...
SPECTSliceThickness*[0:1:size(SPECT, 3)-1]);
% define CT PixelSpacing (these values are taken from CT images)
CTPixelSpacing = [0.9765,0.9765];
CTSliceThickness = 3;
% define the new SPECT matrix using meshgrid
[Xnew, Ynew, Znew] = meshgrid(SPECTPixelSpacing(2)*[0:CTPixelSpacing(2)/SPECTPixelSpacing(2):size(SPECT, 2)],...
SPECTPixelSpacing(1)*[0:CTPixelSpacing(1)/SPECTPixelSpacing(1):size(SPECT, 1)],...
SPECTSliceThickness*[0:CTSliceThickness/SPECTSliceThickness:size(SPECT, 3)]);
% calculate the 3D interpolation
new_SPECT = interp3(Xold, Yold, Zold, SPECT, Xnew, Ynew, Znew );
whos new_SPECT
After resampling I am supposed to have 512*512*263, this is the size of the CT images. However, I'm getting 511*511*132. X and Y dimensions seems ok, but how could I get a correct Z dimension? Any help is appreciated.
0 Kommentare
Antworten (1)
Matt J
am 14 Jun. 2019
You could just use imresize3,
new_SPECT = imresize3(SPECT, [512,512,263])
0 Kommentare
Siehe auch
Kategorien
Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!