Contrast Equalization
Apply contrast equalization to an image.
Enhance image contrast using configurable equalization methods (Contrast Stretching, Histogram Equalization, or Adaptive Equalization) to improve image visibility, distribute pixel intensities more evenly, and enhance details in low-contrast or poorly lit images for preprocessing, enhancement, and quality improvement workflows.
How This Block Works
This block enhances image contrast by redistributing pixel intensities using one of three equalization methods. The block:
Receives an input image to enhance with contrast equalization
Selects the contrast equalization method based on equalization_type parameter
Applies the selected equalization method:
For Contrast Stretching:
Calculates the 2nd and 98th percentiles of pixel intensities in the image (finds the darkest and brightest meaningful values, ignoring extreme outliers)
Stretches the intensity range between these percentiles to span the full 0-255 range
Enhances contrast by expanding the dynamic range while preserving relative intensity relationships
Useful for images with a narrow intensity range that need stretching to full range
For Histogram Equalization:
Normalizes pixel intensities to 0-1 range for processing
Computes and equalizes the image histogram to create a uniform distribution of pixel intensities
Redistributes pixel values so that each intensity level has approximately equal frequency
Scales the equalized values back to 0-255 range
Enhances contrast globally across the entire image, improving visibility of features
For Adaptive Equalization:
Normalizes pixel intensities to 0-1 range for processing
Applies adaptive histogram equalization (CLAHE - Contrast Limited Adaptive Histogram Equalization)
Divides the image into small regions and equalizes each region independently
Uses clip_limit=0.03 to limit contrast enhancement and prevent over-amplification of noise
Combines local equalized regions using bilinear interpolation for smooth transitions
Scales the result back to 0-255 range
Enhances contrast adaptively, preserving local details while improving overall visibility
Preserves image metadata from the original image
Returns the enhanced image with improved contrast
The block provides three methods with different characteristics: Contrast Stretching expands intensity ranges linearly, Histogram Equalization creates uniform intensity distribution globally, and Adaptive Equalization enhances contrast locally while preventing over-amplification. Each method works best for different scenarios - Contrast Stretching for images with narrow intensity ranges, Histogram Equalization for overall contrast improvement, and Adaptive Equalization for images with varying contrast across regions.
Common Use Cases
Image Preprocessing for Models: Enhance image contrast before feeding to detection or classification models (e.g., improve contrast before object detection, enhance visibility before classification, prepare images for model processing), enabling improved model performance workflows
Low-Contrast Image Enhancement: Improve visibility and details in low-contrast or poorly lit images (e.g., enhance dark images, improve visibility in low-light conditions, reveal details in low-contrast scenes), enabling image enhancement workflows
Detail Enhancement: Reveal hidden details in images with poor contrast (e.g., enhance details in shadow regions, reveal features in dark areas, improve visibility of subtle details), enabling detail enhancement workflows
Image Quality Improvement: Improve overall image quality and visibility (e.g., enhance overall image quality, improve visibility for analysis, optimize images for display), enabling image quality workflows
Medical and Scientific Imaging: Enhance contrast in medical or scientific images for better analysis (e.g., enhance medical imaging contrast, improve scientific image visibility, prepare images for analysis), enabling scientific imaging workflows
Document Image Enhancement: Improve contrast in scanned documents or document images (e.g., enhance document contrast, improve text visibility, optimize scanned documents), enabling document enhancement workflows
Connecting to Other Blocks
This block receives an image and produces an enhanced image with improved contrast:
After image input blocks to enhance input images before further processing (e.g., enhance contrast in camera feeds, improve visibility in image inputs, optimize images for workflow processing), enabling image enhancement workflows
Before detection or classification models to improve model performance with better contrast (e.g., enhance images before object detection, improve visibility for classification models, prepare images for model analysis), enabling enhanced model input workflows
After preprocessing blocks to apply contrast enhancement after other preprocessing (e.g., enhance contrast after filtering, improve visibility after transformations, optimize images after preprocessing), enabling multi-stage enhancement workflows
Before visualization blocks to display enhanced images with better visibility (e.g., visualize enhanced images, display improved contrast results, show enhancement effects), enabling enhanced visualization workflows
Before analysis blocks that benefit from improved contrast (e.g., analyze enhanced images, process improved visibility images, work with optimized contrast), enabling enhanced analysis workflows
In image quality improvement pipelines where contrast enhancement is part of a larger enhancement workflow (e.g., enhance images in multi-stage pipelines, improve quality through enhancement steps, optimize images in processing chains), enabling image quality pipeline workflows
Type identifier
Use the following identifier in step "type" field: roboflow_core/contrast_equalization@v1 to add the block as a step in your workflow.
Properties
Name
Type
Description
Refs
name
str
Enter a unique identifier for this step..
❌
equalization_type
str
Type of contrast equalization method to apply: 'Contrast Stretching' stretches the intensity range between 2nd and 98th percentiles to full 0-255 range (linear expansion, good for narrow intensity ranges), 'Histogram Equalization' (default) creates uniform intensity distribution globally (equalizes histogram across entire image, good for overall contrast improvement), or 'Adaptive Equalization' enhances contrast locally in small regions while limiting over-amplification (CLAHE with clip_limit=0.03, good for images with varying contrast). Default is 'Histogram Equalization' which provides good general-purpose contrast enhancement. Choose based on image characteristics and enhancement needs..
✅
The Refs column marks possibility to parametrise the property with dynamic values available in workflow runtime. See Bindings for more info.
Input and Output Bindings
The available connections depend on its binding kinds. Check what binding kinds Contrast Equalization in version v1 has.
Input and output bindings
input
image(image): Input image to enhance with contrast equalization. The block applies one of three contrast equalization methods based on the equalization_type parameter. Works on color or grayscale images. The enhanced image will have improved contrast, better visibility, and enhanced details. Original image metadata is preserved in the output..equalization_type(string): Type of contrast equalization method to apply: 'Contrast Stretching' stretches the intensity range between 2nd and 98th percentiles to full 0-255 range (linear expansion, good for narrow intensity ranges), 'Histogram Equalization' (default) creates uniform intensity distribution globally (equalizes histogram across entire image, good for overall contrast improvement), or 'Adaptive Equalization' enhances contrast locally in small regions while limiting over-amplification (CLAHE with clip_limit=0.03, good for images with varying contrast). Default is 'Histogram Equalization' which provides good general-purpose contrast enhancement. Choose based on image characteristics and enhancement needs..
output
image(image): Image in workflows.
Last updated
Was this helpful?