Operator Reference

equ_histo_image_rectequ_histo_image_rectEquHistoImageRectEquHistoImageRectequ_histo_image_rect (Operator)

equ_histo_image_rectequ_histo_image_rectEquHistoImageRectEquHistoImageRectequ_histo_image_rect — Histogram linearization within a rectangluar mask.

Signature

equ_histo_image_rect(Image : ImageEquHisto : Mode, MaskWidth, MaskHeight, MaxContrast : )

Herror equ_histo_image_rect(const Hobject Image, Hobject* ImageEquHisto, const char* Mode, const Hlong MaskWidth, const Hlong MaskHeight, double MaxContrast)

Herror T_equ_histo_image_rect(const Hobject Image, Hobject* ImageEquHisto, const Htuple Mode, const Htuple MaskWidth, const Htuple MaskHeight, const Htuple MaxContrast)

void EquHistoImageRect(const HObject& Image, HObject* ImageEquHisto, const HTuple& Mode, const HTuple& MaskWidth, const HTuple& MaskHeight, const HTuple& MaxContrast)

HImage HImage::EquHistoImageRect(const HString& Mode, Hlong MaskWidth, Hlong MaskHeight, const HTuple& MaxContrast) const

HImage HImage::EquHistoImageRect(const HString& Mode, Hlong MaskWidth, Hlong MaskHeight, double MaxContrast) const

HImage HImage::EquHistoImageRect(const char* Mode, Hlong MaskWidth, Hlong MaskHeight, double MaxContrast) const

HImage HImage::EquHistoImageRect(const wchar_t* Mode, Hlong MaskWidth, Hlong MaskHeight, double MaxContrast) const   ( Windows only)

static void HOperatorSet.EquHistoImageRect(HObject image, out HObject imageEquHisto, HTuple mode, HTuple maskWidth, HTuple maskHeight, HTuple maxContrast)

HImage HImage.EquHistoImageRect(string mode, int maskWidth, int maskHeight, HTuple maxContrast)

HImage HImage.EquHistoImageRect(string mode, int maskWidth, int maskHeight, double maxContrast)

def equ_histo_image_rect(image: HObject, mode: str, mask_width: int, mask_height: int, max_contrast: Union[float, int]) -> HObject

Description

The operator equ_histo_image_rectequ_histo_image_rectEquHistoImageRectEquHistoImageRectequ_histo_image_rect enhances the contrast. Similar to equ_histo_imageequ_histo_imageEquHistoImageEquHistoImageequ_histo_image, it applies a transformation to linearize the cumulative histogram. However, instead of using the histogram of the whole image, only the local neighborhood of each pixel is considered to compute the transformation. The size of this rectangular neighborhood region can be set by MaskWidthMaskWidthMaskWidthmaskWidthmask_width and MaskHeightMaskHeightMaskHeightmaskHeightmask_height.

The local contrast maximization improves the visibility of low-contrast structures, but also amplifies noise. The parameter MaxContrastMaxContrastMaxContrastmaxContrastmax_contrast can be used to limit the maximum contrast in a local neighborhood, which effectively reduces the amplification of noise. Therefore, the method is also known as Contrast-Limited Adaptive Histogram Equalization (CLAHE).

The parameter ModeModeModemodemode determines the processing mode. In the 'accurate'"accurate""accurate""accurate""accurate" mode, the transformation is computed for each pixel as described above. In the 'fast'"fast""fast""fast""fast" mode, the transformation is computed only for a subset of all pixels and interpolated between those points. Due to the interpolation, the results of both modes can differ significantly.

Attention

The operator equ_histo_image_rectequ_histo_image_rectEquHistoImageRectEquHistoImageRectequ_histo_image_rect primarily serves for optical processing of images for a human viewer. For example, the contrast spreading can lead to a detection of fictitious edges.

Note that filter operators may return unexpected results if an image with a reduced domain is used as input. Please refer to the chapter Filters.

Execution Information

  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).
  • Multithreading scope: global (may be called from any thread).
  • Automatically parallelized on tuple level.
  • Automatically parallelized on channel level.
  • Automatically parallelized on domain level.

Parameters

ImageImageImageimageimage (input_object)  (multichannel-)image(-array) objectHImageHObjectHObjectHobject (byte)

Image to be enhanced.

ImageEquHistoImageEquHistoImageEquHistoimageEquHistoimage_equ_histo (output_object)  (multichannel-)image(-array) objectHImageHObjectHObjectHobject * (byte)

Image with linearized gray values.

ModeModeModemodemode (input_control)  string HTuplestrHTupleHtuple (string) (string) (HString) (char*)

Processing mode.

Default: 'accurate' "accurate" "accurate" "accurate" "accurate"

Suggested values: 'accurate'"accurate""accurate""accurate""accurate", 'fast'"fast""fast""fast""fast"

MaskWidthMaskWidthMaskWidthmaskWidthmask_width (input_control)  extent.x HTupleintHTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Width of the filter mask.

Default: 51

Suggested values: 31, 51, 101, 151

Value range: 1 ≤ MaskWidth MaskWidth MaskWidth maskWidth mask_width

Minimum increment: 2

Restriction: MaskWidth <= width(Image)

MaskHeightMaskHeightMaskHeightmaskHeightmask_height (input_control)  extent.y HTupleintHTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Height of the filter mask.

Default: 51

Suggested values: 31, 51, 101, 151

Value range: 1 ≤ MaskHeight MaskHeight MaskHeight maskHeight mask_height

Minimum increment: 2

Restriction: MaskHeight <= height(Image)

MaxContrastMaxContrastMaxContrastmaxContrastmax_contrast (input_control)  real HTupleUnion[float, int]HTupleHtuple (real / integer) (double / int / long) (double / Hlong) (double / Hlong)

Maximum contrast.

Default: 0.01

Suggested values: 0, 0.01, 0.02, 0.05, 0.1, 0.5, 1

Value range: 0 ≤ MaxContrast MaxContrast MaxContrast maxContrast max_contrast ≤ 1

Complexity

In ModeModeModemodemode='accurate'"accurate""accurate""accurate""accurate", equ_histo_image_rectequ_histo_image_rectEquHistoImageRectEquHistoImageRectequ_histo_image_rect uses an algorithm with constant complexity per pixel, i.e., the runtime only depends on the size of the input image and not on the mask size.

In ModeModeModemodemode='fast'"fast""fast""fast""fast", the number of histograms to be computed depends on the mask size. Hence, the runtime increases with smaller mask sizes and decreases with larger mask sizes.

Possible Successors

disp_imagedisp_imageDispImageDispImagedisp_image

Alternatives

equ_histo_imageequ_histo_imageEquHistoImageEquHistoImageequ_histo_image, scale_imagescale_imageScaleImageScaleImagescale_image, scale_image_maxscale_image_maxScaleImageMaxScaleImageMaxscale_image_max, illuminateilluminateIlluminateIlluminateilluminate

See also

equ_histo_imageequ_histo_imageEquHistoImageEquHistoImageequ_histo_image, scale_imagescale_imageScaleImageScaleImagescale_image

References

S. Pizer et al.: “Adaptive Histogram Equalization and Its Variations”; Computer Vision, Graphics, and Image Processing, vol. 39, no. 3, pp. 355-368, 1987, doi: 10.1016/S0734-189X(87)80186-X.
Philipp Härtinger, Carsten Steger: “Adaptive histogram equalization in constant time”; Journal of Real-Time Image Processing, vol. 21, article 93, 2024, doi: 10.1007/s11554-024-01465-1.

Module

Foundation