Image.invert#

Image.invert() Image[source]#

Invert image

Returns:

_description_

Return type:

_type_

Low becomes high and high becomes low. The resulting image has the same datatype and size as the original image. The transformation is:

For an integer image

\[\begin{split}Y_{u,v} = \left\{ \begin{array}{l} p_{\mbox{max}} \mbox{, if } X_{u,v} = 0 \\ p_{\mbox{min}} \mbox{, otherwise} \end{array}\right.\end{split}\]

where \(p_{\mbox{min}}\) and \(p_{\mbox{max}}\) are respectively the minimum and maximum value of the datatype.

For a float image

\[\begin{split}Y_{u,v} = \left\{ \begin{array}{l} 1.0 \mbox{, if } X_{u,v} = 0 \\ 0.0 \mbox{, otherwise} \end{array}\right.\end{split}\]

Example:

>>> from machinevisiontoolbox import Image
>>> img = Image([[0, 1], [2, 3]])
>>> img.invert().print()
   255 254
   253 252