
- 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 − Window Functions With Images
Window functions with images, refer to a technique used in image processing when applying Fast Fourier Transforms (FFTs). FFTs are mathematical operations that analyze the frequency components of a signal, including images also. When using FFTs with images, it's important to consider that FFTs assume the data represents one period of a periodic signal, causing discontinuities at signal endpoints. These discontinuities distort the output of the FFT and can lead to energy from "real" frequency components spreading into wider frequency ranges.
To reduce this effect of spectral leakage can be done by multiplying the signal or image with a window function. Window functions gently reduce the signal's amplitude near its edges, smoothing out the artificial discontinuities caused by FFT.
The scikit image library provides a function called window() within its filters module to generate an n-dimensional window of a specified size and dimension.
Using the skimage.filters.window() function
The window() function is used to generate an n-dimensional window of a specified size and dimensionality.
Syntax
Following is the syntax of this function −
skimage.filters.window(window_type, shape, warp_kwargs=None)
Parameters
Here are the details of the parameters −
- Window_type (string, float, or tuple): Specifies the type of window to be created. It allows any window types available in SciPy's signal.get_window function.
- Shape (tuple of int or int): Specifies the shape of the window along each axis. If an integer is provided, it generates a 1D window.
- Warp_kwargs (dict): Keyword arguments that can be passed to skimage.transform.warp. These arguments affect the interpolation method used for warping the windowâfor example, warp_kwargs={'order': 3}.
Return value
The function returns a generated window represented as the ndarray of the specified shape. The data type (dtype) of the window is np.float64.
Example
The following example applies the "Hann", "Tukey", and "Hamming windows" to the input image −
import matplotlib.pyplot as plt import numpy as np from skimage import img_as_float, color, io from skimage.filters import window # Load an example image and convert it to grayscale image = img_as_float(color.rgb2gray(io.imread('Images/butterfly.jpg'))) # Apply a Hann window to the image windowed_image_Hann = image * window('hann', image.shape) # Apply a Tukey window with an alpha parameter of 0.8 windowed_image_Tukey = image * window(('tukey', 0.8), image.shape) # Apply a Hamming window to the image windowed_image_Hamming = image * window('hamming', image.shape) # Plot the original and windowed images fig, axes = plt.subplots(2, 2, figsize=(12, 8)) ax = axes.ravel() ax[0].set_title("Original Image") ax[0].imshow(image, cmap='gray') ax[0].axis('off') ax[1].set_title("Hann Windowed Image") ax[1].imshow(windowed_image_Hann, cmap='gray') ax[1].axis('off') ax[2].set_title("Tukey Windowed Image") ax[2].imshow(windowed_image_Tukey, cmap='gray') ax[2].axis('off') ax[3].set_title("Hamming Windowed Image") ax[3].imshow(windowed_image_Hamming, cmap='gray') ax[3].axis('off') plt.tight_layout() plt.show()
Output
Example
In this example, we can see the strong spectral leakage along the x and y axes (observe the vertical and horizontal lines in the "Original FFT" figure ) during the FFT analysis of a standard image. However, the application of a two-dimensional Hann window effectively reduces this spectral leakage issue, resulting in a clearer representation of the "real" frequency information within the FFT's frequency component plot −
import matplotlib.pyplot as plt import numpy as np from scipy.fft import fft2, fftshift from skimage import img_as_float, color, io from skimage.filters import window # Load an example image and convert it to grayscale image = img_as_float(color.rgb2gray(io.imread('Images/rose.jpg'))) # Apply a Hann window to the image windowed_image_Hann = image * window('hann', image.shape) # Compute FFTs of the original and windowed image image_fft = np.abs(fftshift(fft2(image))) windowed_fft_Hann = np.abs(fftshift(fft2(windowed_image_Hann))) # Plot the original image, windowed images, and their FFTs fig, axes = plt.subplots(2, 2, figsize=(12, 8)) ax = axes.ravel() ax[0].set_title("Original Image") ax[0].imshow(image, cmap='gray') ax[0].axis('off') ax[1].set_title("Hann Windowed Image") ax[1].imshow(windowed_image_Hann, cmap='gray') ax[1].axis('off') ax[2].set_title("Original FFT (Frequency)") ax[2].imshow(np.log(image_fft), cmap='magma') ax[2].axis('off') ax[3].set_title("Hann Window + FFT (Frequency)") ax[3].imshow(np.log(windowed_fft_Hann), cmap='magma') ax[3].axis('off') plt.tight_layout() plt.show()