MATLAB Answers

Att
0

different matrix size after 3D interpolation

Asked by Att
on 14 Jun 2019
Latest activity Answered by Matt J
on 14 Jun 2019
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 Comments

Sign in to comment.

1 Answer

Answer by Matt J
on 14 Jun 2019

You could just use imresize3,
new_SPECT = imresize3(SPECT, [512,512,263])

  0 Comments

Sign in to comment.