Differences between revisions 1 and 2
Revision 1 as of 2009-03-23 19:36:04
Size: 44
Comment:
Revision 2 as of 2009-03-23 19:39:56
Size: 414
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
Describe EMAN2/Tutorials/iter_pixels here. = Iterating through the pixels in the EMData object =

In your Python script you can use commands like this to iterate through the pixels in an EMData object
{{{#!python
a = test_image()
for k in a.get_zsize():
    for j in a.get_ysize():
        for i in a.get_xsize():
            pixel_value = a.get(i,j,k) # get the pixel value
            a.set(i,j,k,pixel_value*3) # set the pixel value



}}}

Iterating through the pixels in the EMData object

In your Python script you can use commands like this to iterate through the pixels in an EMData object

   1 a = test_image()
   2 for k in a.get_zsize():
   3     for j in a.get_ysize():
   4         for i in a.get_xsize():
   5             pixel_value = a.get(i,j,k) # get the pixel value
   6             a.set(i,j,k,pixel_value*3) # set the pixel value

EMAN2/Tutorials/iter_pixels (last edited 2015-08-14 22:11:14 by SteveLudtke)