so, to access the rgb of a pixel on position (X, Y), i just use:
matrix[x][y][0] for red
matrix[x][y][1] for green
matrix[x][y][2] for blue
is that right? And what is the best way to go through this matrix? maybe:
for i in matrix:
for j in i:
j[0] = color_red
j[1] = color_green
j[2] = color_blue
is this interaction changing the value of matrix? ( I don't lide the looks of this loop.. :-) )
thanks everyone!
2006/9/8, Edward Catmur <[EMAIL PROTECTED]>:
On Fri, 2006-09-08 at 11:44 -0300, Rodrigo Renie Braga wrote:
> Hello list
>
> I would like to know if there is a (easy) way to grab rgb information
> of an image and then modify it with new rgb information... i'm making
> an application to apply different set of filters on an image, and i
> need to, basicly:
> - load an image
> - be able to grab the rgb information of a certain pixel
> - make a new image with a different rgb (calculated by my algorithm)
> - show that image to the user an then save it to a file
>
> what is the best way to work with rgb and image using pygtk?
You *can* access the pixel data of a GdkPixbuf with
gtk.gdk.Pixbuf.get_pixels (), but that's very slow and painful.
Better is to ensure that PyGtk is compiled with Numeric, and use
gtk.gdk.Pixbuf.get_pixels_array() to get the pixel data (in RGB[A]) as a
Numeric array. You can then apply array transforms to the array using
Numeric. You then recreate a GdkPixbuf from the transformed array with
gtk.gdk.pixbuf_new_from_array(), and save it with gtk.gdk.Pixbuf.save().
Ed
_______________________________________________
pygtk mailing list [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
--
"The best way to sell yourself is to show what you have produced, rather
than tell people what you know, what you want to do, or what degrees you
have." John Carmack
_______________________________________________ pygtk mailing list [email protected] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
