python - numpy and pil reshape arrays -
pil numpy conversion leads arrays like:
a = array([ [[r,g,b],[r,g,b].....[r,g,b],[r,g,b]] , [[r,g,b],[r,g,b.....]] , int8) triplets of rgb values; within rows :
a[0] = [[r,g,b],[r,g,b].....[r,g,b],[r,g,b]] = first row is there quick way convert such triplets numpy arrays , ford (well especialy back..)
a = [[rrrr],[rrrrr],[rrrrr],.... [bbbbb],[bbbbbb],[bbbbbb]...,[ggggg],[ggg],[ggg]] or
like
a=[[rrr],[rrrrr],[.... ...]] **or** aa = [rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr..] b=[[bbb],[bbbbb],[.... ...]]**or** bb = [bbbbbbbbbbbbbbbbbbbbbbbbbb..] c=[[ggg],[ggggg],[.... .]] **or** cc = [ggggggggggggggggggggggggg..] my problem have format aa bb cc , know image size 640x480 how fast pill format below
a = array([ [[r,g,b],[r,g,b].....[r,g,b],[r,g,b]] , [[r,g,b],[r,g,b.....]] , int8)
does a.t give want?
i'm assuming you've created array using numpy's asarray function.
import image, numpy im = image.open('test.png') = numpy.asarray(im) r,g,b,a = a.t the above give 4 separate 2d arrays, 1 each band.
Comments
Post a Comment