resize image
In [ ]:
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')
plt.title(title)
plt.show()
image = imageio.imread('Sharbat_Gula.jpg')
print("Image shape:", image.shape)
In [12]:
resized_image = image[::2, ::2]
print("Resized image shape:", resized_image.shape)
plot_image_from_array(resized_image, title='Resized image')
Resized image shape: (200, 127, 3)
In [13]:
imageio.imwrite('Sharbat_Gula2.jpg', resized_image)
In [14]:
!dir Sharbat_Gula*
Volume in drive H is Google Drive
Volume Serial Number is 1983-1116
Directory of H:\My Drive\0001_projects\2024\AI_Python\14_numpy
20/06/2024 18:39 37,655 Sharbat_Gula.jpg
14/10/2024 09:37 6,070 Sharbat_Gula2.jpg
2 File(s) 43,725 bytes
0 Dir(s) 73,724,489,728 bytes free
