crop image
In [1]:
import imageio.v2 as imageio
import numpy as np
import matplotlib.pyplot as plt
def plot_image_from_array(image_array, title='Image'):
plt.imshow(image_array, cmap='gray')
plt.axis('off') # Hide axes
plt.title(title)
plt.show()
image = imageio.imread('Sharbat_Gula.jpg')
print("Image shape:", image.shape)
plot_image_from_array(image, title='Original')
Image shape: (400, 254, 3)
In [2]:
cropped_image = image[100:200, 100:150]
print("Cropped image shape:", cropped_image.shape)
plot_image_from_array(cropped_image, title='Cropped image')
Cropped image shape: (100, 50, 3)
