Rotations
In cases where an object is angled or flipped, the image can be rotated. Using ndi.rotate(), the image is rotated from its center by the specified degrees from the right horizontal axis.
For this exercise, shift and rotate the brain image (im) so that it is roughly level and "facing" the right side of the image.
Deze oefening maakt deel uit van de cursus
Biomedical Image Analysis in Python
Oefeninstructies
- Shift
imtowards the center: 20 pixels left and 20 pixels up. - Use
ndi.rotateto turnxfm30 degrees downward. Setreshape=Falseto prevent the image shape from changing. - Plot the original and transformed images.
Praktische interactieve oefening
Probeer deze oefening eens door deze voorbeeldcode in te vullen.
# Shift the image towards the center
xfm = ____
# Rotate the shifted image
xfm = ndi.rotate(____, angle=____, reshape=____)
# Plot the original and rotated images
fig, axes = plt.subplots(2, 1)
axes[0].imshow(im)
____
format_and_render_plot()