
- 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 - Visual Image Comparison
Visual image comparison, in general, involves the process of visually inspecting and evaluating two or more images with the human eye. This process requires placing the images side by side or overlaying them to observe and analyze the differences and similarities between them.
Visual image comparison is a valuable technique in the field of image processing, especially when dealing with tasks such as adjusting exposure, applying filters, and restoring images.
The scikit-image library offers the compare_images() function within its util module to perform the Visual image comparison tasks on images.
Using the skimage.util.compare_images() function
This function is used to compare two images and generate a new image that shows the differences between them.
Syntax
Here is the syntax of the function −
skimage.util.compare_images(image1, image2, method='diff', *, n_tiles=(8, 8))
Parameters
Following are the parameters of the function −
image1 and image2 (2-D arrays): These are the two input images that you want to compare. They must be of the same shape.
-
method (string, optional): This parameter specifies the method used for the image comparison. It accepts one of the following values −
'diff': This method computes the absolute difference between the two input images.
'blend': This method computes the mean (average) value of pixel intensities between the two input images.
'checkerboard': This method creates a checkerboard pattern by dividing the image into tiles, where each tile alternates between displaying parts of the first and second input images.
n_tiles (tuple, optional): This parameter is only used when the method is set to 'checkerboard'. It specifies the number of tiles in the checkerboard pattern, with the format (rows, columns).
The function returns a 2-D array, which is an image showing the differences between the two input images based on the selected comparison method.
let's see the various approaches for comparing two images −
Checkerboard
The checkerboard method involves creating a pattern of alternating tiles or squares that display portions of the first and the second images being compared.
Example
The following example demonstrates how to perform image comparison using a checkerboard pattern.
import matplotlib.pyplot as plt from matplotlib.gridspec import GridSpec from skimage import data, transform, exposure from skimage.util import compare_images # Load the original image and perform histogram equalization original_image = data.coins() equalized_image = exposure.equalize_hist(original_image) # Rotate the original image rotated_image = transform.rotate(original_image, 2) # Compare the original and equalized images using the checkerboard method comparison_image = compare_images(original_image, equalized_image, method='checkerboard') # Create a visual comparison display fig = plt.figure(figsize=(8, 9)) grid_spec = GridSpec(3, 2) # Subplots for original and equalized images ax0 = fig.add_subplot(grid_spec[0, 0]) ax1 = fig.add_subplot(grid_spec[0, 1]) # Subplot for the checkerboard comparison ax2 = fig.add_subplot(grid_spec[1:, :]) # Display the original image ax0.imshow(original_image, cmap='gray') ax0.set_title('Original') # Display the equalized image ax1.imshow(equalized_image, cmap='gray') ax1.set_title('Equalized') # Display the checkerboard comparison ax2.imshow(comparison_image, cmap='gray') ax2.set_title('Checkerboard comparison') # Turn off axes for all subplots for a in (ax0, ax1, ax2): a.axis('off') plt.tight_layout() plt.show()
Output

Diff
The diff method computes the absolute difference between the two images to determine how much they vary from each other.
Example
Here is an example that applies the diff method to compare the two images.
import matplotlib.pyplot as plt from matplotlib.gridspec import GridSpec from skimage import data, transform, exposure from skimage.util import compare_images # Load the coins image and perform histogram equalization original_image = data.coins() equalized_image = exposure.equalize_hist(original_image) # Rotate the original image rotated_image = transform.rotate(original_image, 2) # Compare the original and rotated images using the "diff" method comparison_image = compare_images(original_image, rotated_image, method='diff') # Create a visual comparison display fig = plt.figure(figsize=(8, 9)) grid_spec = GridSpec(3, 2) # Subplots for original and rotated images ax0 = fig.add_subplot(grid_spec[0, 0]) ax1 = fig.add_subplot(grid_spec[0, 1]) # Subplot for the "diff" comparison ax2 = fig.add_subplot(grid_spec[1:, :]) # Display the original image ax0.imshow(original_image, cmap='gray') ax0.set_title('Original') # Display the rotated image ax1.imshow(rotated_image, cmap='gray') ax1.set_title('Rotated') # Display the "diff" comparison ax2.imshow(comparison_image, cmap='gray') ax2.set_title('Diff Comparison') for a in (ax0, ax1, ax2): a.axis('off') plt.tight_layout() plt.show()
Output

Blend
The blend method in image comparison calculates the average of pixel values from two images.
Example
Here is an example the demonstrates how to use the compare_images() function to perform a visual image comparison with the "blend" method.
import matplotlib.pyplot as plt from matplotlib.gridspec import GridSpec from skimage import data, transform, exposure from skimage.util import compare_images # Load the coins image and perform histogram equalization original_image = data.coins() equalized_image = exposure.equalize_hist(original_image) # Rotate the original image rotated_image = transform.rotate(original_image, 2) # Compare the original and rotated images using the blend method comparison_image = compare_images(original_image, rotated_image, method='blend') # Create a visual comparison display fig = plt.figure(figsize=(8, 9)) grid_spec = GridSpec(3, 2) # Subplots for original and equalized images ax0 = fig.add_subplot(grid_spec[0, 0]) ax1 = fig.add_subplot(grid_spec[0, 1]) # Subplot for the Blend comparison ax2 = fig.add_subplot(grid_spec[1:, :]) ax0.imshow(original_image, cmap='gray') ax0.set_title('Original') ax1.imshow(rotated_image, cmap='gray') ax1.set_title('Rotated') ax2.imshow(comparison_image, cmap='gray') ax2.set_title('Blend Comparison') # Turn off axes for all subplots for a in (ax0, ax1, ax2): a.axis('off') plt.tight_layout() plt.show()
Output
