I have this image and following python code.
import numpy as np
from PIL import Image
image = Image.open("File.png")
image = image.convert("1")
image.show()
bw = np.asarray(image).copy()
im01 = np.where(bw, 0, 1)
new_img = Image.fromarray(im01)
new_img.show()
Since the image is black and white, I could see the im01 as a 2D ndarray
with 0s and 1 as white and black pixels in 184x184 matrix.
Why didn't Image.fromarray()
work?
Is there something that I am missing?