mirror of
https://github.com/opencv/opencv.git
synced 2025-07-25 06:38:42 +08:00
Fix CLAHE distribution.
Fix CLAHE for 16-bit images.
This commit is contained in:
parent
44e5d26312
commit
c6772a8f5d
@ -212,8 +212,12 @@ namespace
|
|||||||
for (int i = 0; i < histSize; ++i)
|
for (int i = 0; i < histSize; ++i)
|
||||||
tileHist[i] += redistBatch;
|
tileHist[i] += redistBatch;
|
||||||
|
|
||||||
for (int i = 0; i < residual; ++i)
|
if (residual != 0)
|
||||||
tileHist[i]++;
|
{
|
||||||
|
int residualStep = MAX(histSize / residual, 1);
|
||||||
|
for (int i = 0; i < histSize; i += residualStep)
|
||||||
|
tileHist[i]++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// calc Lut
|
// calc Lut
|
||||||
@ -359,7 +363,7 @@ namespace
|
|||||||
bool useOpenCL = cv::ocl::useOpenCL() && _src.isUMat() && _src.dims()<=2 && _src.type() == CV_8UC1;
|
bool useOpenCL = cv::ocl::useOpenCL() && _src.isUMat() && _src.dims()<=2 && _src.type() == CV_8UC1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int histSize = _src.type() == CV_8UC1 ? 256 : 4096;
|
int histSize = _src.type() == CV_8UC1 ? 256 : 65536;
|
||||||
|
|
||||||
cv::Size tileSize;
|
cv::Size tileSize;
|
||||||
cv::_InputArray _srcForLut;
|
cv::_InputArray _srcForLut;
|
||||||
@ -416,7 +420,7 @@ namespace
|
|||||||
if (_src.type() == CV_8UC1)
|
if (_src.type() == CV_8UC1)
|
||||||
calcLutBody = cv::makePtr<CLAHE_CalcLut_Body<uchar, 256, 0> >(srcForLut, lut_, tileSize, tilesX_, clipLimit, lutScale);
|
calcLutBody = cv::makePtr<CLAHE_CalcLut_Body<uchar, 256, 0> >(srcForLut, lut_, tileSize, tilesX_, clipLimit, lutScale);
|
||||||
else if (_src.type() == CV_16UC1)
|
else if (_src.type() == CV_16UC1)
|
||||||
calcLutBody = cv::makePtr<CLAHE_CalcLut_Body<ushort, 4096, 4> >(srcForLut, lut_, tileSize, tilesX_, clipLimit, lutScale);
|
calcLutBody = cv::makePtr<CLAHE_CalcLut_Body<ushort, 65536, 0> >(srcForLut, lut_, tileSize, tilesX_, clipLimit, lutScale);
|
||||||
else
|
else
|
||||||
CV_Error( CV_StsBadArg, "Unsupported type" );
|
CV_Error( CV_StsBadArg, "Unsupported type" );
|
||||||
|
|
||||||
@ -426,7 +430,7 @@ namespace
|
|||||||
if (_src.type() == CV_8UC1)
|
if (_src.type() == CV_8UC1)
|
||||||
interpolationBody = cv::makePtr<CLAHE_Interpolation_Body<uchar, 0> >(src, dst, lut_, tileSize, tilesX_, tilesY_);
|
interpolationBody = cv::makePtr<CLAHE_Interpolation_Body<uchar, 0> >(src, dst, lut_, tileSize, tilesX_, tilesY_);
|
||||||
else if (_src.type() == CV_16UC1)
|
else if (_src.type() == CV_16UC1)
|
||||||
interpolationBody = cv::makePtr<CLAHE_Interpolation_Body<ushort, 4> >(src, dst, lut_, tileSize, tilesX_, tilesY_);
|
interpolationBody = cv::makePtr<CLAHE_Interpolation_Body<ushort, 0> >(src, dst, lut_, tileSize, tilesX_, tilesY_);
|
||||||
|
|
||||||
cv::parallel_for_(cv::Range(0, src.rows), *interpolationBody);
|
cv::parallel_for_(cv::Range(0, src.rows), *interpolationBody);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user