Auto Contrast
This function block automatically adjusts image contrast by analyzing the image histogram and stretching pixel values to enhance visibility. It is ideal for quickly improving brightness and contrast of photos or camera frames without manual curve edits.
π₯ Inputs (sockets)
Image Any β Input socket that accepts the image to be contrast-adjusted.
π€ Outputs (sockets)
Image Any β Output socket that provides the contrast-enhanced image.
πΉοΈ Controls (widgets)
Threshold β Slider to set histogram clipping percentage (range typically 1β99). Higher values clip more extremes before stretching, producing stronger contrast.
βοΈ Running mechanism
When the block runs, it analyzes the input image histogram to find low and high cut points according to the selected Threshold value. It then rescales pixel values so the useful tonal range fills the available output range. The result is a visually brighter and higher-contrast image while trying to preserve details within the clipped range.
π¨ Features
Automatic histogram clipping to expand usable tonal range.
Single-slider control for fast, intuitive adjustments.
Works with grayscale and color images.
Fast operation suitable for real-time preview and batch processing.
π Usage
Connect an image source to the
Image Anyinput (for exampleCamera USB,Camera IP (ONVIF),Load Image).Adjust the
Thresholdslider to control how aggressively the histogram is clipped.Use the block output
Image Anyas input to visualization or further processing blocks (for exampleShow Image,Image Logger,Image Write).
π‘ Tips and Tricks
Combine with
DenoisingorBlurbefore contrast enhancement to reduce noise amplification on very noisy images.Use
Normalize Imageif you need a different normalization strategy or want to match contrast to a reference image.After auto contrast, fine-tune results with
Contrast-Brightness-Gammafor more precise control over midtones and gamma.Preview results with
Show Imageduring tuning, and save preferred results withImage WriteorImage Logger.When working with specific color issues, try
Adjust ColorsorColor Spacebefore applying auto contrast to get better color balance.
π οΈ Troubleshooting
Output looks too harsh or clipped: reduce the
Thresholdvalue to preserve more highlights/shadows.Loss of detail in highlights/shadows: try a lower
Thresholdor follow withContrast-Brightness-Gammaadjustments.Increased visible noise after enhancement: apply
Denoisingbefore auto contrast, or reduceThreshold.Color shifts after processing: experiment with
Color Spaceconversion orAdjust Colorsbefore applying auto contrast.
β
Best practices
Start with a low-to-moderate
Thresholdand increase until the desired contrast is reached.Use
Show Imageto compare before/after in real time.For automated pipelines, test threshold settings on a representative set of images to avoid over/under-processing.
Last updated
Was this helpful?