Absolute Difference

tomni.illumination_correction.absolute_difference(img: numpy.ndarray, gauss_size: int = 21, new_median: int = 128) numpy.ndarray[source]

Remove large blurry artifacts from an image by taking the absolute difference between the blurred and original image.

Parameters
  • img (numpy.ndarray) – The input image.

  • gauss_size (int, optional) – The size of the Gaussian filter kernel for blurring. Must be an odd number. Defaults to 21.

  • new_median (int, optional) – The target median value for the resulting image. Defaults to 128.

Returns

The processed image with blurry artifacts removed.

Return type

numpy.ndarray

Warning

  • This function is not suitable for human vision and may produce artifacts.

  • The gauss_size should be an odd number; if it’s even, it will be incremented by 1.

Note

This algorithm is fractal, meaning that applying illumination correction followed by cropping will yield the same result as cropping first.