Contrast Enhancement
Enhance image contrast by normalizing the histogram to use the full dynamic range.
Enhance image contrast using histogram normalization (the algorithm from GIMP's Auto Levels). This block stretches the image histogram to use the full available range [0-255], improving visibility of features with low contrast.
How This Block Works
Channel Analysis: For grayscale images, find min/max directly. For color images, analyze each channel independently.
Histogram Normalization: For each channel, stretch values from [min, max] to [0, 255] using linear scaling:
output = (input - min) / (max - min) * 255Clipping: Values outside [0, 255] are clipped to the valid range
Common Use Cases
Low-contrast medical imaging: Normalize tissue visibility across varying acquisition parameters
Industrial inspection: Enhance subtle surface defects on dull materials
Surveillance footage: Improve nighttime or backlit scene visibility
Document scanning: Brighten poorly lit document photos
Microscopy: Boost signal from weak fluorescence or phase-contrast images
Input Parameters
image : Input image to enhance (color or grayscale)
Can be single-channel, 3-channel (BGR), or 4-channel (BGRA)
Each channel is normalized independently for color images
clip_limit : Percentage of histogram range to skip at extremes (default: 0)
Range: 0-50
0: No clipping, entire histogram from min to max is used
1-3: Skip dark and bright outliers (robust to noise)
5-10: Very aggressive outlier removal
20-50: Extreme outlier removal, may lose subtle details
contrast_multiplier : Multiplier for contrast scaling after normalization (default: 1.0)
Range: 0.1-5.0
1.0: No additional scaling, just normalization
0.5-0.9: Reduce contrast for smoother images
1.1-2.0: Increase contrast for more dramatic enhancement
normalize_brightness : Apply brightness normalization using midtone equalization (default: False)
False: Only histogram normalization and contrast scaling
True: After histogram normalization, apply midtone adjustment for balanced brightness
Outputs
image : Enhanced image with normalized contrast, same shape and type as input
Notes
Sensitive to outliers: Extreme min/max values (single dark/bright pixels) stretch most of the histogram into a narrow range. Use morphological opening (Morphological Transformation v2) as preprocessing to remove spurious dark/bright specks.
Color shift: For color images, each channel stretches independently, which can shift hue if channels have very different dynamic ranges
Efficiency: Very fast - linear scan for min/max, then linear transformation per pixel
Brightness normalization: When enabled, applies midtone stretch (gamma ≈ 1.3) for more balanced perceived brightness
Type identifier
Use the following identifier in step "type" field: roboflow_core/contrast_enhancement@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..
❌
clip_limit
int
Percentage of histogram range to skip at dark and bright extremes. 0: use full range from min to max. 1-3: skip outliers (robust). 5-10: very aggressive outlier removal..
❌
contrast_multiplier
float
Multiplier for contrast scaling after normalization. 1.0: no additional scaling (just histogram normalization). <1.0: reduce contrast. >1.0: increase contrast for more dramatic enhancement..
❌
normalize_brightness
bool
Apply brightness normalization using midtone equalization. When False, only histogram normalization and contrast scaling are applied. When True, applies midtone adjustment for more balanced perceived brightness..
❌
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 Enhancement in version v1 has.
Last updated
Was this helpful?