Concept Flow - Image rotation and zoom
Load Image Data
Apply Rotation
Apply Zoom
Output Transformed Image
The image is first loaded, then rotated by a given angle, followed by zooming in or out, resulting in a transformed image.
from scipy.ndimage import rotate, zoom import numpy as np image = np.array([[1,2],[3,4]]) rotated = rotate(image, 90, reshape=False) zoomed = zoom(rotated, 2)
| Step | Action | Input Shape | Parameters | Output Shape | Output Snapshot |
|---|---|---|---|---|---|
| 1 | Load Image | - | - | (2, 2) | [[1, 2], [3, 4]] |
| 2 | Rotate Image | (2, 2) | angle=90, reshape=False | (2, 2) | [[2, 4], [1, 3]] |
| 3 | Zoom Image | (2, 2) | zoom=2 | (4, 4) | [[2, 2, 4, 4], [2, 2, 4, 4], [1, 1, 3, 3], [1, 1, 3, 3]] |
| Variable | Start | After Rotation | After Zoom |
|---|---|---|---|
| image | [[1, 2], [3, 4]] | [[1, 2], [3, 4]] | [[1, 2], [3, 4]] |
| rotated | N/A | [[2, 4], [1, 3]] | [[2, 4], [1, 3]] |
| zoomed | N/A | N/A | [[2, 2, 4, 4], [2, 2, 4, 4], [1, 1, 3, 3], [1, 1, 3, 3]] |
Image rotation and zoom with scipy.ndimage: - Use rotate(image, angle, reshape=False) to rotate without changing shape. - Use zoom(image, factor) to resize. - Rotation keeps shape for square images when reshape=False. - Zoom multiplies image dimensions. - Output is a transformed numpy array.