On Fri, Sep 08, 2006 at 02:32:25PM -0300, Rodrigo Renie Braga wrote: > ok, i'm doing some tests here with Numeric, and it seems that the > gtk.gdk.Pixbuf.get_pixels_array() returns an (Numeric) array with the > following shape: (w, h, 3), meaning a matrix with a dimension of WxHx3 ... > > 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.. :-) )
The last time I did this, I used indexes into the Array. I don't know if your method will actually update the values in matrix or a copy that is generated by the for loop. You of course will get better performance if you can eliminate the loop. Can you create the data you want through some kind of matrix operation (multiplication, addition, etc.)? _______________________________________________ pygtk mailing list [email protected] http://www.daa.com.au/mailman/listinfo/pygtk Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
