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
Post a Comment