I am new to Python, I want to read a image like jpg,png. and convert it to binary image. Here is my work:
from PIL import Image
import numpy
def main( ):
name= 'b.jpg'
img= Image.open (name);
for pixel in iter(img.getdata()):
print(pixel)
img.convert("1").show();
del image;
if __name__=='__main__':
main()