Friday 15 April 2011

numpy - Python Imaging Processing (PIL) - changing the overall RGB of an image -



numpy - Python Imaging Processing (PIL) - changing the overall RGB of an image -

i trying alter rgb overall image project. working test file before apply actual image. want test different values of rgb first start mean of three. how go doing this? have other modules installed such scipy, numpy, matplotlib, etc if needed. thanks

from pil import image, imagefilter test = image.open('/users/meganrcunninghan/pictures/4th-of-july-wallpaper.ppm') test.show() test.getrgb()

assuming image stored numpy.ndarray (test print type(test))...

your image represented nxmx3 array. means have n m image color depth of 3- rgb values. taking mean of 3 leave nxmx1 array, 1 average intensity. numpy well:

test = test.mean(2)

the parameter given, 2, specifies dimension take mean along. either 0, 1, or 2, because image matrix 3 dimensional. should homecoming nxm array. left gray-scale, (color depth of 1) image. seek show value gets returned! if nx3 or mx3, know have taken average along wrong axis. note can check dimensions of numpy array with:

test.shape

shape tuple describing dimensions of image.

python-2.7 numpy python-imaging-library rgb

No comments:

Post a Comment