0
0
SciPydata~10 mins

Image rotation and zoom in SciPy - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to rotate the image by 45 degrees using scipy.

SciPy
from scipy.ndimage import rotate
rotated_image = rotate(image, [1])
Drag options to blanks, or click blank then click option'
A45
B90
C30
D60
Attempts:
3 left
💡 Hint
Common Mistakes
Using radians instead of degrees.
Forgetting to import rotate from scipy.ndimage.
2fill in blank
medium

Complete the code to zoom the image by a factor of 2 using scipy.

SciPy
from scipy.ndimage import zoom
zoomed_image = zoom(image, [1])
Drag options to blanks, or click blank then click option'
A0.5
B1
C2
D3
Attempts:
3 left
💡 Hint
Common Mistakes
Using a zoom factor less than 1 to enlarge the image.
Confusing zoom factor with pixel dimensions.
3fill in blank
hard

Fix the error in the code to rotate the image without changing its shape.

SciPy
rotated_image = rotate(image, 30, [1]=False)
Drag options to blanks, or click blank then click option'
Amode
Border
Cprefilter
Dreshape
Attempts:
3 left
💡 Hint
Common Mistakes
Using mode or order instead of reshape.
Not setting reshape parameter at all.
4fill in blank
hard

Fill both blanks to zoom the image by 1.5 and rotate it by 90 degrees.

SciPy
zoomed_image = zoom(image, [1])
rotated_image = rotate(zoomed_image, [2])
Drag options to blanks, or click blank then click option'
A1.5
B90
C45
D2
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up zoom factor and rotation angle.
Using 45 degrees instead of 90 for rotation.
5fill in blank
hard

Fill all three blanks to rotate the image by 180 degrees, zoom by 0.75, and keep the original shape after rotation.

SciPy
rotated_image = rotate(image, [1], [2]=False)
final_image = zoom(rotated_image, [3])
Drag options to blanks, or click blank then click option'
Areshape
B180
C0.75
Dorder
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting reshape=False causes shape change.
Using zoom factor greater than 1 when shrinking is needed.