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()
由于图像是黑白的,因此我可以将im01视为2D ndarray
,在184x184矩阵中为0和1为黑白像素。
Image.fromarray()
为什么不起作用?
有什么我想念的吗?