Removing the last value in the 2D array in Python -


i running code, outputs value of image array 4 values rgb , alpha, how remove last value rgb im dealing with.

from pil import image, imagefilter import numpy np  imagelocation = image.open("images/numbers/0.1.png")  #creates array [3d] of image colours imagearray = np.asarray(imagelocation)  print(imagearray) 

this output each pixel , want rgb output not 4th column.

[[[255 255 255 255]   [255 255 255 255]   [  0   0   0 255]   [  0   0   0 255]   [  0   0   0 255]   [  0   0   0 255]   [255 255 255 255]   [255 255 255 255]] 

you can slice numpy arrays so:

rgb = my_array[:,:,:3] 

also since you're using pil:

im = image.open("path/to/image") rgb = im.convert('rgb') 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -