How to use WarpedView to interpolate a 3D image

imresize defined by the given ratio can be defined as an image warping by the linear transformation of matrix:

[ 1 0 0 ; 
  0 1 0; 
  0 0 z_res/xy_res]

But the image warping is implemented via backward transformation:

using Images, ImageTransformations, CoordinateTransformations, Interpolations
function  invtform(xy_res, z_res)  #inverse transformation
    M=[1 0 0 ; 0 1 0; 0 0 xy_res/z_res]
    LinearMap(M)
end 
img = load("image-3d.tif");
xy_res = 120
a, b, c= size(img)
imgw =  warpedview(img, invtform(xy_res, c), 
          (1:a, 1:b, 1:round(Int, c^2/xy_res)); method=Lanczos(4)) 
1 Like