-
Notifications
You must be signed in to change notification settings - Fork 102
Image Resampling
Aditi Iyer edited this page Jan 26, 2023
·
4 revisions
global planC
indexS = planC{end};
% Specify scan & structure
scanNum = 1;
strNum = 3;
% Get scan and mask
scan3M = double(getScanArray(scanNum,planC));
CToffset = planC{indexS.scan}(scanNum).scanInfo(1).CTOffset;
scan3M = scan3M - double(CToffset);
mask3M = getStrMask(strNum,planC);
% Get input grid, origin & resolution
[xValsV, yValsV, zValsV] = getScanXYZVals(planC{indexS.scan}(scanNum));
if yValsV(1) > yValsV(2)
yValsV = fliplr(yValsV);
end
originV = [xValsV(1),yValsV(1),zValsV(end)];
% Specify resampling parameters
outputResV = [0.1 0.1 0.15]
resampleMethod = 'linear'; %select from: 'linear','cubic','nearest',
%'makima','spline','sinc'.
roiResampleMethod = 'linear';
gridAlignMethod = 'center';
extrapVal = 0;
[xResampleV,yResampleV,zResampleV] = ...
getResampledGrid(outputResV,xValsV,yValsV,zValsV,originV,gridAlignMethod);
outScan3M = imgResample3d(double(scan3M),xValsV,yValsV,zValsV,...
xResampleV,yResampleV,zResampleV,resampleMethod,extrapVal);
outMask3M = imgResample3d(single(mask3M),xValsV,yValsV,...
zValsV,xResampleV,yResampleV,zResampleV,roiResampleMethod) >= 0.5;
% Add resampled scan to to planC
scanInfoS.horizontalGridInterval = outputResV(1);
scanInfoS.verticalGridInterval = outputResV(2);
scanInfoS.coord1OFFirstPoint = xResampleV(1);
scanInfoS.coord2OFFirstPoint = yResampleV(1);
scanInfoS.zValues = zResampleV;
sliceThicknessV = diff(zResampleV);
scanInfoS.sliceThickness = [sliceThicknessV,sliceThicknessV(end)];
% Add resampled mask to planC
planC = scan2CERR(outScan3M,'scan1_resampled','',scanInfoS,'',planC);
newScanNum = length(planC{indexS.scan});
strName = 'struct_resampled';
planC = maskToCERRStructure(outMask3M,0,newScanNum,strName,planC);