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

  1. Connect an image source to the Image Any input (for example Camera USB, Camera IP (ONVIF), Load Image).

  2. Adjust the Threshold slider to control how aggressively the histogram is clipped.

  3. Use the block output Image Any as input to visualization or further processing blocks (for example Show Image, Image Logger, Image Write).

πŸ’‘ Tips and Tricks

  • Combine with Denoising or Blur before contrast enhancement to reduce noise amplification on very noisy images.

  • Use Normalize Image if you need a different normalization strategy or want to match contrast to a reference image.

  • After auto contrast, fine-tune results with Contrast-Brightness-Gamma for more precise control over midtones and gamma.

  • Preview results with Show Image during tuning, and save preferred results with Image Write or Image Logger.

  • When working with specific color issues, try Adjust Colors or Color Space before applying auto contrast to get better color balance.

πŸ› οΈ Troubleshooting

  • Output looks too harsh or clipped: reduce the Threshold value to preserve more highlights/shadows.

  • Loss of detail in highlights/shadows: try a lower Threshold or follow with Contrast-Brightness-Gamma adjustments.

  • Increased visible noise after enhancement: apply Denoising before auto contrast, or reduce Threshold.

  • Color shifts after processing: experiment with Color Space conversion or Adjust Colors before applying auto contrast.

βœ… Best practices

  • Start with a low-to-moderate Threshold and increase until the desired contrast is reached.

  • Use Show Image to 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?