1. An apparatus configured to filter an image, comprising: a memory; and a processor coupled to the memory, the processor, in conjunction with the memory, configured to, separately for each pixel location at a horizontal or vertical block boundary of the image: calculate a perceptual masking factor at the pixel location at the block boundary of the image, calculate a parameter for a filter at the pixel location at the block boundary by minimizing a regularized cost function for the parameter, and filter the image around the pixel location at the block boundary employing the filter with the calculated parameter.