(template parameter) Histogram type, see calcHistogram function for details.
Input image slice.
Histogram values for input image slice.
Optional pre-allocated buffer where equalized image is saved.
Copy of input image slice with its histogram values equalized.
1 import dcv.core, dcv.io, dcv.imgproc, dcv.plot; 2 3 void main() 4 { 5 Image image = imread("dcv/examples/data/lena.png"); 6 7 auto slice = image.sliced.rgb2gray; 8 auto equalized = slice.histEqualize(slice.flattened.calcHistogram); 9 10 slice.imshow("Original"); 11 equalized.imshow("Equalized"); 12 13 waitKey(); 14 }
Example code will equalize grayscale Lena image, from this:
$(IMAGE https://github.com/libmir/dcv/blob/master/examples/data/lena_gray.png?raw=true)
... to this:
$(IMAGE https://github.com/libmir/dcv/blob/master/examples/data/histEqualExample.png?raw=true)
Note: For more valid color histogram equalization results, try converting image to HSV color model to perform equalization for V channel, to alter the color as less as possible.
Histogram Equalization.
Equalize histogram of given image slice. Slice can be 2D for grayscale, and 3D for color images. If 3D slice is given, histogram is applied separatelly for each channel.