When reading frames from a camera or video with ixfx, you get back ImageData instances.
This can be worked with directly to read pixel values at given locations, or iterated over to read every pixel. Pixel values are given as red, green, blue and opacity (or alpha) values on a 0..255 scale in one single array. Four array positions are thus used to represent a single pixel.
That is:
Here’s the basic way to read pixels using ImageData directly:
ixfx’s helper functions can read pixels in way that makes code more literate. However, if you’re also wanting to modify pixels, you may be better off using the above technique, since you have all the raw array indexes at-hand.
Reading pixels by x,y
Or the same example as earlier, reading through every pixel, left-to-right, top-to-bottom.
By row or column
You can also scan by row and column, with generators. These will yield an array of pixel values for the row or column.