Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

So, yeah. The 16-bit CLAHE is broken. I've fixed it once for work, but I can't commit it here.

Working from memory, here are the changes, all in clahe.cpp

Line 215: for (int i = 0; i < histSize; i += histSize/residual)

Line 360: int histSize = _src.type() == CV_8UC1 ? 256 : 65536;

Line 417: calcLutBody = cv::makePtr<clahe_calclut_body<ushort, 65535,="" 0=""> >(srcForLut, lut_, tileSize, tilesX_, clipLimit, lutScale);

Line 427: interpolationBody = cv::makePtr<clahe_interpolation_body<ushort, 0=""> >(src, dst, lut_, tileSize, tilesX_, tilesY_);

Then your clip limit should be ~500, is my experience. I'm re-building to test these changes, and downloading an IR dataset. I'll edit once I'm done. I don't suppose I could see the raw 16bit of yours to show?

So, yeah. The 16-bit CLAHE is broken. I've fixed it once for work, but I can't commit it here.

Working from memory, here are the changes, all in clahe.cpp

Line 215: int residualStep = MAX(histSize / residual, 1); for (int i = 0; i < histSize; i += histSize/residual)residualStep)

Line 360: int histSize = _src.type() == CV_8UC1 ? 256 : 65536;

Line 417: calcLutBody = cv::makePtr<clahe_calclut_body<ushort, 65535,="" 0=""> >(srcForLut, lut_, tileSize, tilesX_, clipLimit, lutScale);

Line 427: interpolationBody = cv::makePtr<clahe_interpolation_body<ushort, 0=""> >(src, dst, lut_, tileSize, tilesX_, tilesY_);

Then your clip limit should be ~500, is my experience. I'm re-building to test these changes, and downloading an IR dataset. I'll edit once I'm done. I don't suppose I could see the raw 16bit of yours to show?

So, yeah. The 16-bit CLAHE is broken. I've fixed it once for work, but I can't commit it here.

Working from memory, here are the changes, all in clahe.cpp

Line 215: 215:

 int residualStep = MAX(histSize / residual, 1);
for (int i = 0; i < histSize; i += residualStep)

Line 360: residualStep)

Line 360:

 int histSize = _src.type() == CV_8UC1 ? 256 : 65536;

Line 417: 65536;

Line 417:

 calcLutBody = cv::makePtr<clahe_calclut_body<ushort, 65535,="" 0=""> cv::makePtr<CLAHE_CalcLut_Body<ushort, 65535, 0> >(srcForLut, lut_, tileSize, tilesX_, clipLimit, lutScale);

lutScale);

Line 427:

interpolationBody = cv::makePtr<clahe_interpolation_body<ushort, 0=""> cv::makePtr<CLAHE_Interpolation_Body<ushort, 0> >(src, dst, lut_, tileSize, tilesX_, tilesY_);

tilesY_);

Then your clip limit should be ~500, is my experience. I'm re-building to test these changes, and downloading an IR dataset. I'll edit once I'm done. I don't suppose I could see the raw 16bit of yours to show?

EDIT: Line 215 also needs a divide by zero check. Use this block of code.

int residualStep = histSize;
if(residual != 0)
    residualStep = MAX(histSize / residual, 1);
for (int i = 0; i < histSize; i += residualStep)
    tileHist[i]++;

I've tested, and these changes do work. So basically you're changing the final distribution in the histogram slightly (which should improve 8-bit quality as well), using the full 16-bit range, and changing the shift in the template parameters to 0.

So, yeah. The 16-bit CLAHE is broken. I've fixed it once for work, but I can't commit it here.

Working from memory, here are the changes, all in clahe.cpp

Line 215:

 int residualStep = MAX(histSize / residual, 1);
for (int i = 0; i < histSize; i += residualStep)

Line 360:

 int histSize = _src.type() == CV_8UC1 ? 256 : 65536;

Line 417:

 calcLutBody = cv::makePtr<CLAHE_CalcLut_Body<ushort, 65535, 0> >(srcForLut, lut_, tileSize, tilesX_, clipLimit, lutScale);

Line 427:

interpolationBody = cv::makePtr<CLAHE_Interpolation_Body<ushort, 0> >(src, dst, lut_, tileSize, tilesX_, tilesY_);

Then your clip limit should be ~500, is my experience. I'm re-building to test these changes, and downloading an IR dataset. I'll edit once I'm done. I don't suppose I could see the raw 16bit of yours to show?

EDIT: Line 215 also needs a divide by zero check. Use this block of code.

int residualStep = histSize;
if(residual if (residual != 0)
 {
   int residualStep = MAX(histSize / residual, 1);
 for (int i = 0; i < histSize; i += residualStep)
     tileHist[i]++;
}

I've tested, and these changes do work. So basically you're changing the final distribution in the histogram slightly (which should improve 8-bit quality as well), using the full 16-bit range, and changing the shift in the template parameters to 0.