python - Converting a PNG image to 2D array -


i have png file when convert image numpy array, of format 184 x 184 x 4. image 184 184 , each pixel in rgba format , hence 3d array.

this b&w image , pixels either [255, 255, 255, 255] or [0, 0, 0, 255].

i want convert 184 x 184 2d array pixels either 1 or 0, depending upon if [255, 255, 255, 255] or [0, 0, 0, 255].

any ideas how straightforward conversion of this.

if there 2 values in array say, scale , return 1 of dimensions:

(arr[:,:,0] / 255).astype(int) 

Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -