added faster cythonic version of per_pixel_correction