Python PIL Black and White Image to 2D array

Viewed 362

I am trying to use the python PIL library to convert an image to black and white and then extract the pixels as a 2d array of 0's and 1's.

So far I am able to convert the image to black and white as follows:

bwImage = Image.open(imageFilePath)   
bwImage = bwImage.convert(mode="1", dither=Image.NONE)

But from here I don't know how to extract each pixel as a numeric value and enter it into the array. I have tried sum of the numpy functions like asarray() and array() but these don't seem to work for 1-bit images.

0 Answers
Related