Interpolation
Interpolation is how new pixel intensities are estimated when an image transformation is applied. It is implemented in SciPy using sets of spline functions.
Editing the interpolation order
when using a function such as ndi.zoom()
modifies the resulting estimate: higher orders provide more flexible estimates but take longer to compute.
For this exercise, upsample im
and investigate the effect of different interpolation orders on the resulting image.
Diese Übung ist Teil des Kurses
Biomedical Image Analysis in Python
Anleitung zur Übung
- Use
ndi.zoom()
to upsampleim
from a shape of128, 128
to512, 512
twice. First, use an interpolationorder
of 0, then setorder
to 5. - Print the array shapes of
im
andup0
. - Plot close-ups of the images. Use the index range
128:256
along each axis.
Interaktive Übung
Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.
# Upsample "im" by a factor of 4
up0 = ndi.zoom(____, zoom=____, order=____)
up5 = ____
# Print original and new shape
print('Original shape:', ____)
print('Upsampled shape:', ____)
# Plot close-ups of the new images
fig, axes = plt.subplots(1, 2)
axes[0].imshow(up0[128:256, 128:256])
axes[1].imshow(____)
format_and_render_plots()