def rotation_matrix1(section, _windows=windows):
    rot_filters = windows(section.reshape(5, 5), (3, 3)).reshape(9, 9)
return rot_filters[(rot_filters.std(1).argmin()), :].mean()
Optimizing implementation of a rotating mask in numpy/scipy