First time here? Check out the FAQ!

Ask Your Question
4

Difference of CLAHE between opencv and matlab

asked Jun 19 '13

statcomp gravatar image

updated Jun 19 '13

I am trying to translate our Matlab code into C++ with OpenCV. Among others, finding counter part of adapthist of Matlab in OpenCV is critical. The function does so-called Contrast-limited adaptive histogram equalization (CLAHE) Luckily, OpenCV 2.45 came with CLAHE and I can neatly run following code for it.

Ptr<CLAHE> clahe = createCLAHE();
clahe->setClipLimit(3); //****
clahe->setTilesGridSize(Size(8,8));
clahe->apply(input,output);

One problem for matching Matlab result, however, is that ClipLimit in Matlab has range of (0,1) while I don't have any idea about ClipLimit in OpenCV although I think it's usually more than 1.

So could anyone tell me what's the range of ClipLimit in OpenCV and how can it match with the one in Matlab?

Preview: (hide)

2 answers

Sort by » oldest newest most voted
3

answered Jun 20 '13

Vladislav Vinogradov gravatar image

clipLimit parameter in OpenCV has range (0, 256). Real integer clip limit is calculated as

uiClipLimit = fClipLimit * tileSize.width * tileSize.height / 256
Preview: (hide)

Comments

1

FYI: result values from CLAHE between opencv and matlab do not match even with clipLimit values you suggested. I suspect there is fundamental difference in calculation, maybe in histogram calculation.

statcomp gravatar imagestatcomp (Jun 20 '13)edit
0

answered Oct 28 '15

AMG gravatar image

Vladislav, Could you please show how to set all parameters for CLAHE? So far I found setClipLimit and setTilesGridSize, but Matlab allows more parameters to be modified. Thanks.

Preview: (hide)

Question Tools

Stats

Asked: Jun 19 '13

Seen: 4,086 times

Last updated: Jun 20 '13