edit: it's an image so the suggested (How can I efficiently process a numpy array in blocks similar to Matlab's blkproc (blockproc) function) isn't really working for me
I have the following matlab code
fun = @(block_struct) ...
std2(block_struct.data) * ones(size(block_struct.data));
B=blockproc(im2double(Icorrected), [4 4], fun);
b = np.std(a, axis = 2)
I did the following
io.use_plugin('pil', 'imread') a = io.imread('C:\Users\Dimitrios\Desktop\polimesa\\arizona.jpg') B = np.zeros((len(a)/2 +1, len(a)/2 +1)) for i in xrange(0, len(a), 2): for j in xrange(0, len(a), 2): x.append(a[i][j]) if i+1 < len(a): x.append(a[i+1][j]) if j+1 < len(a): x.append(a[i][j+1]) if i+1 < len(a) and j+1 < len(a): x.append(a[i+1][j+1]) B[i/2][j/2] = np.std(x) x[:] = 
and i think it's correct. Iterating over the image by 2 and taking each neighbour node, adding them to a list and calculating std.
edit* later edited for 4x4 blocks.