Update: Using PixelBender to Crunch Numbers
March 7th, 2009 by RobI didn’t realize it, but there’s a bug in PixelBender for Flash when using image4 input. In my case, I have x-y coordinates, and I was trying to operate on two at a time using image4. Can’t do it (yet). The kernel craps out after 60 elements.
Of course, you’re not allowed to output 2- or 1-element pixels, so you have to use image3 for input. What to do? It’s simple really: Say you have a Vector of numbers representing pairs (coordinates, in my case). The first pixel with contain x,y,x and the second y,x,y and so on. All you have to do is check the current pixel’s x-coordinate (assuming the height of your PixelBender input is set to 1) and do the calculations in one or the other order.
Note that in PixelBender, the x,y of the pixel (as reported by outCoord()) is the midpoint of the pixel, so x=0.5,1.5,2.5 and so on. To determine which order to take the calculations in, you just need to know whether x is even or odd.