-
Notifications
You must be signed in to change notification settings - Fork 17
/
clahe.h
72 lines (57 loc) · 3.38 KB
/
clahe.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//*****************************************************************************
// Contrast Limited Adaptive Histogram Equalization (CLAHE) for OpenCV
//-----------------------------------------------------------------------------
// Original CLAHE implementation by Karel Zuiderveld, [email protected]
// in "Graphics Gems IV", Academic Press, 1994.
//-----------------------------------------------------------------------------
// Converted to OpenCV format by Toby Breckon, [email protected]
// Copyright (c) 2009 School of Engineering, Cranfield University
// License : LGPL - http://www.gnu.org/licenses/lgpl.html
//-----------------------------------------------------------------------------
// Improved by Shervin Emami on 17th Nov 2010, [email protected]
// http://www.shervinemami.co.cc/
//*****************************************************************************
#include <cv.h> // open cv general include file
// *****************************************************************************
// CLAHE input/output range flag definitions
#define CV_CLAHE_RANGE_FULL 0
#define CV_CLAHE_RANGE_INPUT 1
// *****************************************************************************
// cvAdaptEqualize(src, dst, xdivs, ydivs, bins)
//
// src - pointer to source image (must be single channel 8-bit)
// dst - pointer to destination image (must be single channel 8-bit)
// xdivs - number of cell divisions to use in vertical (x) direction (MIN=2 MAX = 16)
// ydivs - number of cell divisions to use in vertical (y) direction (MIN=2 MAX = 16)
// bins - number of histogram bins to use per division
// range - either of CV_CLAHE_RANGE_INPUT or CV_CLAHE_RANGE_FULL to limit the output
// pixel range to the min/max range of the input image or the full range of the
// pixel depth (8-bit in this case)
void cvAdaptEqualize(IplImage *src, IplImage *dst,
unsigned int xdivs, unsigned int ydivs, unsigned int bins, int range);
// cvCLAdaptEqualize(src, dst, xdivs, ydivs, bins, limit)
//
// src - pointer to source image (must be single channel 8-bit)
// dst - pointer to destination image (must be single channel 8-bit)
// xdivs - number of cell divisions to use in vertical (x) direction (MIN=2 MAX = 16)
// ydivs - number of cell divisions to use in vertical (y) direction (MIN=2 MAX = 16)
// bins - number of histogram bins to use per division
// limit - contrast limit for localised changes in contrast
// range - either of CV_CLAHE_RANGE_INPUT or CV_CLAHE_RANGE_FULL to limit the output
// pixel range to the min/max range of the input image or the full range of the
// pixel depth (8-bit in this case)
void cvCLAdaptEqualize(IplImage *src, IplImage *dst,
unsigned int xdivs, unsigned int ydivs, unsigned int bins, float limit,
int range);
// *****************************************************************************
/*
redefine : CV_ERROR_LOCAL macro unconditionally raises error with passed code and message.
After raising error, control will be transferred to the exit label.
*/
#undef CV_ERROR
#define CV_ERROR( Code, Msg ) \
{ \
cvError( (Code), "CLAHE code", Msg, __FILE__, __LINE__ ); \
exit(1); \
}
// *****************************************************************************