
- Scikit Image – Introduction
- Scikit Image - Image Processing
- Scikit Image - Numpy Images
- Scikit Image - Image datatypes
- Scikit Image - Using Plugins
- Scikit Image - Image Handlings
- Scikit Image - Reading Images
- Scikit Image - Writing Images
- Scikit Image - Displaying Images
- Scikit Image - Image Collections
- Scikit Image - Image Stack
- Scikit Image - Multi Image
- Scikit Image - Data Visualization
- Scikit Image - Using Matplotlib
- Scikit Image - Using Ploty
- Scikit Image - Using Mayavi
- Scikit Image - Using Napari
- Scikit Image - Color Manipulation
- Scikit Image - Alpha Channel
- Scikit Image - Conversion b/w Color & Gray Values
- Scikit Image - Conversion b/w RGB & HSV
- Scikit Image - Conversion to CIE-LAB Color Space
- Scikit Image - Conversion from CIE-LAB Color Space
- Scikit Image - Conversion to luv Color Space
- Scikit Image - Conversion from luv Color Space
- Scikit Image - Image Inversion
- Scikit Image - Painting Images with Labels
- Scikit Image - Contrast & Exposure
- Scikit Image - Contrast
- Scikit Image - Contrast enhancement
- Scikit Image - Exposure
- Scikit Image - Histogram Matching
- Scikit Image - Histogram Equalization
- Scikit Image - Local Histogram Equalization
- Scikit Image - Tinting gray-scale images
- Scikit Image - Image Transformation
- Scikit Image - Scaling an image
- Scikit Image - Rotating an Image
- Scikit Image - Warping an Image
- Scikit Image - Affine Transform
- Scikit Image - Piecewise Affine Transform
- Scikit Image - ProjectiveTransform
- Scikit Image - EuclideanTransform
- Scikit Image - Radon Transform
- Scikit Image - Line Hough Transform
- Scikit Image - Probabilistic Hough Transform
- Scikit Image - Circular Hough Transforms
- Scikit Image - Elliptical Hough Transforms
- Scikit Image - Polynomial Transform
- Scikit Image - Image Pyramids
- Scikit Image - Pyramid Gaussian Transform
- Scikit Image - Pyramid Laplacian Transform
- Scikit Image - Swirl Transform
- Scikit Image - Morphological Operations
- Scikit Image - Erosion
- Scikit Image - Dilation
- Scikit Image - Black & White Tophat Morphologies
- Scikit Image - Convex Hull
- Scikit Image - Generating footprints
- Scikit Image - Isotopic Dilation & Erosion
- Scikit Image - Isotopic Closing & Opening of an Image
- Scikit Image - Skelitonizing an Image
- Scikit Image - Morphological Thinning
- Scikit Image - Masking an image
- Scikit Image - Area Closing & Opening of an Image
- Scikit Image - Diameter Closing & Opening of an Image
- Scikit Image - Morphological reconstruction of an Image
- Scikit Image - Finding local Maxima
- Scikit Image - Finding local Minima
- Scikit Image - Removing Small Holes from an Image
- Scikit Image - Removing Small Objects from an Image
- Scikit Image - Filters
- Scikit Image - Image Filters
- Scikit Image - Median Filter
- Scikit Image - Mean Filters
- Scikit Image - Morphological gray-level Filters
- Scikit Image - Gabor Filter
- Scikit Image - Gaussian Filter
- Scikit Image - Butterworth Filter
- Scikit Image - Frangi Filter
- Scikit Image - Hessian Filter
- Scikit Image - Meijering Neuriteness Filter
- Scikit Image - Sato Filter
- Scikit Image - Sobel Filter
- Scikit Image - Farid Filter
- Scikit Image - Scharr Filter
- Scikit Image - Unsharp Mask Filter
- Scikit Image - Roberts Cross Operator
- Scikit Image - Lapalace Operator
- Scikit Image - Window Functions With Images
- Scikit Image - Thresholding
- Scikit Image - Applying Threshold
- Scikit Image - Otsu Thresholding
- Scikit Image - Local thresholding
- Scikit Image - Hysteresis Thresholding
- Scikit Image - Li thresholding
- Scikit Image - Multi-Otsu Thresholding
- Scikit Image - Niblack and Sauvola Thresholding
- Scikit Image - Restoring Images
- Scikit Image - Rolling-ball Algorithm
- Scikit Image - Denoising an Image
- Scikit Image - Wavelet Denoising
- Scikit Image - Non-local means denoising for preserving textures
- Scikit Image - Calibrating Denoisers Using J-Invariance
- Scikit Image - Total Variation Denoising
- Scikit Image - Shift-invariant wavelet denoising
- Scikit Image - Image Deconvolution
- Scikit Image - Richardson-Lucy Deconvolution
- Scikit Image - Recover the original from a wrapped phase image
- Scikit Image - Image Inpainting
- Scikit Image - Registering Images
- Scikit Image - Image Registration
- Scikit Image - Masked Normalized Cross-Correlation
- Scikit Image - Registration using optical flow
- Scikit Image - Assemble images with simple image stitching
- Scikit Image - Registration using Polar and Log-Polar
- Scikit Image - Feature Detection
- Scikit Image - Dense DAISY Feature Description
- Scikit Image - Histogram of Oriented Gradients
- Scikit Image - Template Matching
- Scikit Image - CENSURE Feature Detector
- Scikit Image - BRIEF Binary Descriptor
- Scikit Image - SIFT Feature Detector and Descriptor Extractor
- Scikit Image - GLCM Texture Features
- Scikit Image - Shape Index
- Scikit Image - Sliding Window Histogram
- Scikit Image - Finding Contour
- Scikit Image - Texture Classification Using Local Binary Pattern
- Scikit Image - Texture Classification Using Multi-Block Local Binary Pattern
- Scikit Image - Active Contour Model
- Scikit Image - Canny Edge Detection
- Scikit Image - Marching Cubes
- Scikit Image - Foerstner Corner Detection
- Scikit Image - Harris Corner Detection
- Scikit Image - Extracting FAST Corners
- Scikit Image - Shi-Tomasi Corner Detection
- Scikit Image - Haar Like Feature Detection
- Scikit Image - Haar Feature detection of coordinates
- Scikit Image - Hessian matrix
- Scikit Image - ORB feature Detection
- Scikit Image - Additional Concepts
- Scikit Image - Render text onto an image
- Scikit Image - Face detection using a cascade classifier
- Scikit Image - Face classification using Haar-like feature descriptor
- Scikit Image - Visual image comparison
- Scikit Image - Exploring Region Properties With Pandas
Scikit Image - Image Inversion
Image inversion, also known as image negation or image complement, refers to the process of reversing the intensity values of an image. Inverting an image results in a new image where the brightest pixels become the darkest and vice versa.
The process of inverting an image varies depending on the type of image data.
- Binary Images: inversion changes True values to False and vice versa.
- Grayscale Images: For grayscale images, each pixel value is replaced by the difference between the maximum value allowed by the data type (for example, 255 for 8-bit images) and the original pixel value. This will flip the brightness levels, making dark areas appear bright and vice versa.
- RGB Images: In the case of color images represented as RGB (Red, Green, Blue) channels, the inversion operation is applied independently to each channel. Each channel is inverted following the same approach as grayscale images.
To perform image inversion using the scikit-image library, you can use the invert() function from the util submodule of the scikit-image library.
Inverting an image using Scikit Image
The skimage.util.invert() method is used to reverse the intensity range of an input image. The maximum value of the data type becomes the minimum, and vice versa. The behavior of this operation varies depending on the data type of the input:
- For unsigned integers, the image is subtracted from the maximum value of the data type.
- For signed integers, the image is subtracted from -1. This approach is used because the range of signed integers is asymmetric. For example, if the input image is of type np.int8 (range [-128, 127]), by multiplying the image by -1, the maximum value would become 128 which is outside the valid range. By subtracting from -1, the maximum value 128 correctly maps to the value 127.
- For floating-point numbers, if the 'signed_float' parameter is set to False (assuming the image is unsigned), the image is subtracted from 1. If 'signed_float' is set to True, the subtraction is performed with 0.
Syntax
Following is the syntax of this method −
skimage.util.invert(image, signed_float=False)
Parameters
- image: The input image in CIE-Luv color space. The shape of the array should be at least 2-D with the last dimension having a size of 3, representing the CIE-Luv channels.
- signed_float (optional): A boolean flag. When True and the image is of type float, the range is assumed to be [-1, 1]. When False and the image is of type float, the range is assumed to be [0, 1].
Return Value
This method returns the inverted image as an ndarray.
Example
The following example, the original binary image is inverted using the util.invert() function.
import numpy as np from skimage import util, io import matplotlib.pyplot as plt # Create a binary image binary_image = np.array([[False, True, False], [True, False, True], [False, True, False]]) # Invert the binary image inverted_binary_image = util.invert(binary_image) # Display the input and output images using Matplotlib fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(10, 5)) axes[0].imshow(binary_image) axes[0].set_title('Input Binary Image') axes[0].axis('off') axes[1].imshow(inverted_binary_image) axes[1].set_title('Output Inverted Binary Image') axes[1].axis('off') plt.tight_layout() plt.show()
Output
When you run the above program, it will generate the following output −

Example
The following example does the grayscale image inversion using the util.invert() function.
import numpy as np from skimage import io, util import matplotlib.pyplot as plt # Read an image image = io.imread('Images/Tajmahal.jpg', as_gray=True) # Invert the Gray scale image inverted_gray_image = util.invert(image) # Display the input and output images using Matplotlib fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(10, 5)) axes[0].imshow(image) axes[0].set_title('Input Gray Image') axes[0].axis('off') axes[1].imshow(inverted_gray_image) axes[1].set_title('Output Inverted Gray Image') axes[1].axis('off') plt.tight_layout() plt.show()
Output
On executing the above program, you will get the following output.

Example
In the following example, the original RGB image will be inverted using the util.invert() function.
import numpy as np from skimage import io, util import matplotlib.pyplot as plt # Read an image image = io.imread('Images/Tajmahal.jpg') # Invert the RGB image inverted_rgb_image = util.invert(image) # Display the input and output images using Matplotlib fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(10, 5)) axes[0].imshow(image) axes[0].set_title('Input RGB Image') axes[0].axis('off') axes[1].imshow(inverted_rgb_image) axes[1].set_title('Output Inverted RGB Image') axes[1].axis('off') plt.tight_layout() plt.show()
Output
On executing the above program, you will get the following output.
