0

Is there any function for computing expansion and reduction for 3D images in matlab? For example, something to reduce 3D-volume from 170*240*240 to 85*120*120 or to expand from 85*120*120 to 170*240*240.

'impyramid' in matlab does similar but only reduce and expand in the first 2 dimension.

I also saw this function https://www.mathworks.com/matlabcentral/fileexchange/12037-gaussian-pyramid-expand-and-reduce-routines-1d--2d-and-3d on mathworks file exchange but it is relatively slow for 3D-volume.

Tee
  • 385
  • 3
  • 14

1 Answers1

3

Memory expensive and slow way to do it, and probably the only way of really doing it:

% Desired size
sz=[120 , 56, 123]; %whatever

[y, x, z]=...
   ndgrid(linspace(1,size(img,1),sz(1)),...
          linspace(1,size(img,2),sz(2)),...
          linspace(1,size(img,3),sz(3)));

imOut=interp3(img,x,y,z);
clear x y z 

You can save some time (or expend more!) by providing a method to interp3.

nearest will be cheaper but less accurate. The rest more expensive computaionally.

Ander Biguri
  • 35,140
  • 11
  • 74
  • 120