I am working with vImages in Cocoa Touch, which in my case are basically ARGB-float-Arrays, and I need to do a subsampling. Low pass filtering is no problem using the vImage functions but how do I select one out 2x2 pixels (assuming I want to subsample by factor 2)? Of course I could use a vDSP stride function, but this only works for horizontal subsampling, not vertical subsampling.
I hope the following will clarify what I intend to do. I wish to select all pixels marked with an X as shown in this image:
X O X O X O
O O O O O O
X O X O X O
O O O O O O
X O X O X O
O O O O O O
But since the memory is linear, my array looks like this:
X O X O X O O O O O O O X O X O X O O O O O O O X O X O X O O O O O O O
How can I perform subsampling in a reasonable fashion?
EDIT: I am looking for an efficient way to do a two dimensional downsampling of a given bitmap stored as a one dimensional float-array (that includes negative values).