different matrix size after 3D interpolation

12 vues (au cours des 30 derniers jours)
Att
Att le 14 Juin 2019
Réponse apportée : Matt J le 14 Juin 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.

Réponses (1)

Matt J
Matt J le 14 Juin 2019
You could just use imresize3,
new_SPECT = imresize3(SPECT, [512,512,263])

Catégories

En savoir plus sur Image Processing Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by