Ask Your Question
4

Difference of CLAHE between opencv and matlab

asked 2013-06-19 15:37:03 -0600

statcomp gravatar image

updated 2013-06-19 15:38:44 -0600

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?

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
3

answered 2013-06-20 03:00:59 -0600

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
edit flag offensive delete link more

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 ( 2013-06-20 15:32:55 -0600 )edit
0

answered 2015-10-28 09:21:01 -0600

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.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-06-19 15:37:03 -0600

Seen: 4,046 times

Last updated: Jun 20 '13