From a64a5e2fef850789e066e536e28a8ea6e31bd206 Mon Sep 17 00:00:00 2001 From: Justin Israel Date: Sat, 28 Feb 2026 14:30:18 +1300 Subject: [PATCH] Add MagickWand.CLAHEImage() (fixes #334) --- imagick/magick_wand_image.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/imagick/magick_wand_image.go b/imagick/magick_wand_image.go index 0af23a8..5db3a60 100644 --- a/imagick/magick_wand_image.go +++ b/imagick/magick_wand_image.go @@ -232,6 +232,20 @@ func (mw *MagickWand) ChopImage(width, height uint, x, y int) error { return mw.getLastErrorIfFailed(ok) } +// CLAHEImage is a variant of adaptive histogram equalization in which the contrast amplification is limited, +// so as to reduce this problem of noise amplification. +// +// width: the width of the tile divisions to use in horizontal direction +// height: the height of the tile divisions to use in vertical direction +// numberBins: number of bins for histogram ("dynamic range") (usually 256). +// clipLimit: contrast limit for localised changes in contrast. A limit less than 1 results in standard +// non-contrast limited AHE + +func (mw *MagickWand) CLAHEImage(width, height uint, numberBins, clipLimit float64) error { + ok := C.MagickCLAHEImage(mw.mw, C.size_t(width), C.size_t(height), C.double(numberBins), C.double(clipLimit)) + return mw.getLastErrorIfFailed(ok) +} + // ClampImage Restricts the color range from 0 to the quantum depth func (mw *MagickWand) ClampImage() error { ok := C.MagickClampImage(mw.mw)