我想打开一个bmp图像,找到所有的黑色像素,然后将它们改为白色,并显示新的图像。但是我不能用PIL。所以我需要用很难的方法。到目前为止,我的情况是:
with open('image.bmp', 'rb') as f:
f.seek(18)
# The width and height are 4 bytes each, so read 8 bytes to get both of them
bytes = f.read(8)
size = struct.unpack('<II', bytes)
# Print the width and height of the image
print('Image width: ' + str(size[0]))
print('Image height: ' + str(size[1]))
现在我想迭代图像,找到所有黑色的像素。但是我怎么知道一个像素是黑色的呢? 最后我可以把它保存成新的_图像.bmp但是我如何在画布中显示它(我使用的是Tkinter)?你知道吗
谢谢
目前没有回答
相关问题 更多 >
编程相关推荐