LoslegenKostenlos loslegen

Resampling

Images can be collected in a variety of shapes and sizes. Resampling is a useful tool when these shapes need to be made consistent. Two common applications are:

  • Downsampling: combining pixel data to decrease size
  • Upsampling: distributing pixel data to increase size

For this exercise, transform and then resample the brain image (im) to see how it affects image shape.

Diese Übung ist Teil des Kurses

Biomedical Image Analysis in Python

Kurs anzeigen

Anleitung zur Übung

  • Shift im 20 pixels left and 20 pixels up, i.e. (-20, -20). Then, rotate it 35 degrees downward. Remember to specify a value for reshape.
  • Use ndi.zoom() to downsample the image from (256, 256) to (64, 64).
  • Use ndi.zoom() to upsample the image from (256, 256) to (1024, 1024).
  • Plot the resampled images.

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# Center and level image
xfm = ndi.shift(____, shift=____)
xfm = ndi.rotate(____, angle=____, reshape=____)

# Resample image
im_dn = ndi.zoom(xfm, zoom=____)
im_up = ____

# Plot the images
fig, axes = plt.subplots(2, 1)
axes[0].imshow(im_dn)
____
format_and_render_plot()
Code bearbeiten und ausführen