skimage 0.17.2

NotesParametersReturnsBackRef
invert(image, signed_float=False)

Invert the intensity range of the input image, so that the dtype maximum is now the dtype minimum, and vice-versa. This operation is slightly different depending on the input dtype:

See the examples for clarification.

Notes

Ideally, for signed integers we would simply multiply by -1. However, signed integer ranges are asymmetric. For example, for np.int8, the range of possible values is [-128, 127], so that -128 * -1 equals -128! By subtracting from -1, we correctly map the maximum dtype value to the minimum.

Parameters

image : ndarray

Input image.

signed_float : bool, optional

If True and the image is of type float, the range is assumed to be [-1, 1]. If False and the image is of type float, the range is assumed to be [0, 1].

Returns

inverted : ndarray

Inverted image.

Invert an image.

Examples

This example is valid syntax, but we were not able to check execution
>>> img = np.array([[100,  0, 200],
...  [ 0, 50, 0],
...  [ 30, 0, 255]], np.uint8)
... invert(img) array([[155, 255, 55], [255, 205, 255], [225, 255, 0]], dtype=uint8)
This example is valid syntax, but we were not able to check execution
>>> img2 = np.array([[ -2, 0, -128],
...  [127, 0, 5]], np.int8)
... invert(img2) array([[ 1, -1, 127], [-128, -1, -6]], dtype=int8)
This example is valid syntax, but we were not able to check execution
>>> img3 = np.array([[ 0., 1., 0.5, 0.75]])
... invert(img3) array([[1. , 0. , 0.5 , 0.25]])
This example is valid syntax, but we were not able to check execution
>>> img4 = np.array([[ 0., 1., -1., -0.25]])
... invert(img4, signed_float=True) array([[-0. , -1. , 1. , 0.25]])
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

skimage.util._invert.invert

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /skimage/util/_invert.py#5
type: <class 'function'>
Commit: