Skip to main content
`Ctrl`+`K`

# ImageNormalize

class astropy.visualization.ImageNormalize(data=None, interval=None, vmin=None, vmax=None, stretch=<astropy.visualization.stretch.LinearStretch object>, clip=False, invalid=-1.0)

  Bases: `Normalize`

  Normalization class to be used with Matplotlib.

  Parameters:
    data `ndarray`, optional

      The image array. This input is used only if `interval` is also input. `data` and `interval` are used to compute the vmin and/or vmax values only if `vmin` or `vmax` are not input.

    interval `BaseInterval` subclass instance, optional

      The interval object to apply to the input `data` to determine the `vmin` and `vmax` values. This input is used only if `data` is also input. `data` and `interval` are used to compute the vmin and/or vmax values only if `vmin` or `vmax` are not input.

    vmin, vmax `python:float`, optional

      The minimum and maximum levels to show for the data. The `vmin` and `vmax` inputs override any calculated values from the `interval` and `data` inputs.

    stretch `BaseStretch` subclass instance

      The stretch object to apply to the data. The default is `LinearStretch`.

    clip bool, optional

      If `True`, data values outside the [0:1] range are clipped to the [0:1] range.

    invalid `python:None` or `python:float`, optional

      Value to assign NaN values generated by this class. NaNs in the input `data` array are not changed. For matplotlib normalization, the `invalid` value should map to the matplotlib colormap “under” value (i.e., any finite value < 0). If `None`, then NaN values are not replaced. This keyword has no effect if `clip=True`.

  Notes

  If `vmin == vmax`, the input data will be mapped to 0.

  Parameters:
    vmin, vmax `python:float` or `python:None`

      Values within the range `[vmin, vmax]` from the input data will be linearly mapped to `[0, 1]`. If either vmin or vmax is not provided, they default to the minimum and maximum values of the input, respectively.

    clip bool, default: `python:False`

      Determines the behavior for mapping values outside the range `[vmin, vmax]`.

      If clipping is off, values outside the range `[vmin, vmax]` are also transformed, resulting in values outside `[0, 1]`. This behavior is usually desirable, as colormaps can mark these under and over values with specific colors.

      If clipping is on, values below vmin are mapped to 0 and values above vmax are mapped to 1. Such values become indistinguishable from regular boundary values, which may cause misinterpretation of the data.

  Notes

  If `vmin == vmax`, input data will be mapped to 0.

  Attributes Summary

  `clip` |
  `vmax` |
  `vmin` |

  Methods Summary

  `__call__`(values[, clip, invalid]) | Transform values using this normalization.
  `autoscale`(A) | Set vmin, vmax to min, max of A.
  `autoscale_None`(A) | If vmin or vmax are not set, use the min/max of A to set them.
  `inverse`(values[, invalid]) | Maps the normalized value (i.e., index in the colormap) back to image data value.
  `process_value`(value) | Homogenize the input value for easy and efficient normalization.
  `scaled`() | Return whether vmin and vmax are both set.

  Attributes Documentation

  clip
  vmax
  vmin

  Methods Documentation

  __call__(values, clip=None, invalid=None)

    Transform values using this normalization.

    Parameters:
      values numpy:array_like

        The input values.

      clip bool, optional

        If `True`, values outside the [0:1] range are clipped to the [0:1] range. If `None` then the `clip` value from the `ImageNormalize` instance is used (the default of which is `False`).

      invalid `python:None` or `python:float`, optional

        Value to assign NaN values generated by this class. NaNs in the input `data` array are not changed. For matplotlib normalization, the `invalid` value should map to the matplotlib colormap “under” value (i.e., any finite value < 0). If `None`, then the `ImageNormalize` instance value is used. This keyword has no effect if `clip=True`.

  autoscale(A)

    Set vmin, vmax to min, max of A.

  autoscale_None(A)

    If vmin or vmax are not set, use the min/max of A to set them.

  inverse(values, invalid=None)

    Maps the normalized value (i.e., index in the colormap) back to image data value.

    Parameters:
      value

        Normalized value.

  static process_value(value)

    Homogenize the input value for easy and efficient normalization.

    value can be a scalar or sequence.

    Parameters:
      value

        Data to normalize.

    Returns:
      result `masked` `array`

        Masked array with the same shape as value.

      is_scalar bool

        Whether value is a scalar.

    Notes

    Float dtypes are preserved; integer types with two bytes or smaller are converted to np.float32, and larger types are converted to np.float64. Preserving float32 when possible, and using in-place operations, greatly improves speed for large arrays.

  scaled()

    Return whether vmin and vmax are both set.