
- 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 datatypes
A datatype, in the context of computer programming, refers to the classification or categorization of data based on its properties and the operations that can be performed on it. It determines how the computer interprets, stores, and manipulates the data.
Different programming languages have their own set of data types, and each data type has its properties. Common data types include integers, floating-point numbers, characters, strings, booleans, and arrays.
Datatypes in Python Scikit Image
In scikit-image, images are represented as numpy arrays and support a variety of data types, also known as "dtypes." The library sets certain ranges for dtype to avoid distorting image intensities. The following are the commonly used dtypes and their corresponding ranges in scikit-image −
- uint8 − Unsigned 8-bit integer, ranging from 0 to 255.
- uint16 − Unsigned 16-bit integer, ranging from 0 to 65535.
- uint32 − Unsigned 32-bit integer, ranging from 0 to 2^32 - 1.
- float − Floating-point values, typically ranging from -1 to 1 or 0 to 1.
- int8 − Signed 8-bit integer, ranging from -128 to 127.
- int16 − Signed 16-bit integer, ranging from -32768 to 32767.
- int32 − Signed 32-bit integer, ranging from -2^31 to 2^31 - 1.
Note that float images should typically be restricted to the range -1 to 1, even though the float dtype itself can exceed this range. On the other hand, integer dtypes can span the entire range of their respective data types. It's important to stick to these ranges to avoid data loss or incorrect interpretations of pixel intensities.
Image data type conversion functions
In scikit-image, there are few functions available in skimage.util module to convert image data types and ensure the proper rescaling of image intensities. These functions are designed to handle the conversion and rescaling while preserving the data range of the image. Following are the image data type conversion functions in scikit-image −
- Img_as_float
- Img_as_ubyte
- Img_as_uint
- Img_as_int
These functions provide a convenient way to convert images to the desired data type while maintaining the correct range of intensities. Also, it is important to avoid using the astype function directly on an image, as it can violate assumptions about the dtype range. Instead, you can use the above conversion functions to ensure proper dtype conversion and intensity rescaling.
Example 1
The following example demonstrates the difference between using the astype() method and the img_as_float() function for converting the data type of an image array in scikit-image.
from skimage import util import numpy as np # Create an image with 8-bit unsigned integers image = np.random.randint(0, 256, size=(1, 4), dtype=np.uint8) print("Image array:", image) # Convert the image to float using astype() print('Converted to float using astype :',image.astype(float)) # These float values are out of range. # Convert the image to float using img_as_float() print("Converted to float using img_as_float:",util.img_as_float(image))
Output
Image array: [[173 104 167 25]] Converted to float using astype : [[173. 104. 167. 25.]] Converted to float using img_as_float: [[0.67843137 0.40784314 0.65490196 0.09803922]]
By using the img_as_float() function, the image array is correctly converted to the floating point data type with the intensity values properly scaled within the valid range.
This ensures proper datatype conversion and intensity rescaling.
Example 2
The following example demonstrates the conversion of a floating-point image array to an 8-bit unsigned integer representation using the img_as_ubyte() function from the skimage.util module.
from skimage import util import numpy as np # Create an image with floating point numbers image = np.array([0, 0.1, 0, 0.8, 0.3, 1], dtype=float) print("Image array:", image) # Convert the image data to 8-bit Unsigned integers print("Converted to 8-bit uint using img_as_ubyte:",util.img_as_ubyte(image))
Output
Image array: [0. 0.1 0. 0.8 0.3 1.] Converted to 8-bit uint using img_as_ubyte: [0 26 0 204 76 255]