Resampling and interpolation

Biomedical Image Analysis in Python

Stephen Bailey

Instructor

Resampling changes the array shape

different-sampling

Biomedical Image Analysis in Python

Downsampling

vol = imageio.volread('OAS1_0255')
vol.shape
(256, 256, 256)

original-brain

vol_dn = ndi.zoom(vol, zoom=0.5)
vol_dn.shape
(128, 128, 128)

downsampled-brain

Biomedical Image Analysis in Python

Upsampling

  • Resampling to a larger grid

  • Not the same as collecting higher-resolution data

  • Useful for standardizing sampling rates that are unequal

vol_up = ndi.zoom(vol, zoom=2)
vol_up.shape
(512, 512, 512)

original-brain

Biomedical Image Analysis in Python

Interpolation

  • "Stitches together" grid points to model the space between points.

$$ Interpolation\ in\ 1\ D $$

Interspolation in 1D

Biomedical Image Analysis in Python

Interpolation

  • "Stitches together" grid points to model the space between points.

  • Nearest-neighbor: uses the closest measured value.

$$ Interpolation\ in\ 1\ D $$

Interpolation in 1D nearest neighbor

Biomedical Image Analysis in Python

Interpolation

  • "Stitches together" grid points to model the space between points.

  • Nearest-neighbor: uses the closest measured value.

    • order = 0
  • B-spline interpolation: models space between points with spline functions of a specified order.

    • order is between 1 and 5

$$ Interpolation\ in\ 1\ D $$

Interpolation B-spline

Biomedical Image Analysis in Python

Interpolation in 2D

im=np.arange(100).reshape([10,10])

Color ascending toy image

zm1=ndi.zoom(im, zoom=10, order=0)
zm2=ndi.zoom(im, zoom=10, order=2)
zm3=ndi.zoom(im, zoom=10, order=4)

Color ascending multi order image

Biomedical Image Analysis in Python

Let's practice!

Biomedical Image Analysis in Python

Preparing Video For Download...