source files: xheq.[ch]
(require "xg.3d.imageops-xheq") (send <grl> :EQUALIZE-HISTOGRAM [ :ADD-NOISE ] )
As usual, <grl> should have two-dimensional CLASS-UNIT-FLOAT-ARRAY arrays :PIXEL-RED, :PIXEL-GREEN and :PIXEL-BLUE, holding an image.
This call enhances the human-visible contrast in am image by trying attempting to make all brightness values equally common in the image.
The call functions by internally constructing a histogram giving the number of times each of the 256 possible brightness values appears in the image, constructing a lookup table mapping each old brightness value to a new brightness value in such a way as to make the new brightness histogram as flat as possible, and then remapping all pixels in the image.
If the :ADD-NOISE keyword is specified, a small random offset is added to output pixel brightnesses to reduce colorbanding. Another, perhaps better, way of reducing colorbanding is to use :RESIZE-IMAGE to blur the image resulting from :EQUALIZE-HISTOGRAM.