sunkit_image.enhance.mgn(data, *, sigma=None, k=0.7, gamma=3.2, h=0.7, weights=None, truncate=3, clip=True, gamma_min=None, gamma_max=None)[source]#

Multi-scale Gaussian normalization.

This function can be used to visualize information over a wide range of spatial scales. It works by normalizing the image by calculating local mean and standard deviation over many spatial scales by convolving with Gaussian kernels of different standard deviations. All the normalized images are then arctan transformed (similar to a gamma transform). Then all the images are combined by adding all of them after multiplying with suitable weights. This method can be used to reveal information and structures at various spatial scales.


  • In practice, the weights and h may be adjusted according to the desired output, and also according to the type of input image (e.g. wavelength or channel). For most purposes, the weights can be set equal for all scales.

  • We do not deal with NaN (Not a Number) in this implementation.

  • The input data array should be normalized by the exposure time.

  • The input data array should be dtype float.

  • data (numpy.ndarray, – Image to be transformed.

  • sigma (list of float, optional) – Range of Gaussian widths (i.e. the standard deviation of the Gaussian kernel) to transform over. Defaults to [1.25, 2.5, 5, 10, 20, 40].

  • k (float, optional) – The scaling factor multiplied with each Gaussian transformed image before applying the arctan transformation. Essentially controls the severity of the arctan transformation. Defaults to 0.7.

  • gamma (float, optional) – The value used to calculate the global gamma-transformed image. Ideally should be between 2.5 to 4 according to the paper. Defaults to 3.2.

  • gamma_min (float, optional) – Minimum input to the gamma transform. Defaults to minimum value of data.

  • gamma_max (float, optional) – Maximum input to the gamma transform. Defaults to maximum value of data.

  • h (float, optional) – Weight of global filter to Gaussian filters. Defaults to 0.7.

  • weights (list, optional) – Used to weight all the transformed images during the calculation of the final image. Defaults to all weights are one.

  • truncate (int, optional) – The number of sigmas to truncate the kernel. Defaults to 3.

  • clip (bool, optional) – If set to True it will clip all the non-positive values in the image to a very small positive value. Defaults to True.


numpy.ndarray or – Normalized image. If a map is input, a map is returned with new data and the same metadata.


  • Huw Morgan and Miloslav Druckmüller. “Multi-scale Gaussian normalization for solar image processing.” Sol Phys 289, 2945-2955, 2014 doi:10.1007/s11207-014-0523-9