반응형
test.py
# PIL module to read and save an image.
from PIL import Image
import matplotlib.pyplot as plt
# Opening image and converting it into grayscale.
img = Image.open('image2.png').convert('L')
# convert PIL Image object to numpy array
img = np.array(img)
# We process img_grayscale and obtain img_processed
img_processed = image_processing(img)
# Converting ndarray to a PIL Image.
img_out = Image.fromarray(img_processed)
# Save the image to a file.
img_out.save('file_name.png')
# Display the image in grayscale
plt.imshow(img_processed, 'gray')plt.show()
반응형
댓글