CTA_SIZE = 256
};
-static inline int getNearestPowerOf2OpenCL(int value)
-{
- int p = 0;
- while (1 << p < value)
- ++p;
- return p;
-}
-
static int divUp(int a, int b)
{
return (a + b - 1) / b;
// additional optimization of precalced weights to replace division(averaging) by binary shift
CV_Assert(templateWindowSize <= 46340); // sqrt(INT_MAX)
int templateWindowSizeSq = templateWindowSize * templateWindowSize;
- almostTemplateWindowSizeSqBinShift = getNearestPowerOf2OpenCL(templateWindowSizeSq);
+ almostTemplateWindowSizeSqBinShift = getNearestPowerOf2(templateWindowSizeSq);
FT almostDist2ActualDistMultiplier = (FT)(1 << almostTemplateWindowSizeSqBinShift) / templateWindowSizeSq;
const FT WEIGHT_THRESHOLD = 1e-3f;
static bool ocl_fastNlMeansDenoising(InputArray _src, OutputArray _dst, float h,
int templateWindowSize, int searchWindowSize)
{
- int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type);
+ int type = _src.type(), cn = CV_MAT_CN(type);
Size size = _src.size();
- if ( !(depth == CV_8U && cn <= 4 && cn != 3) )
+ if ( type != CV_8UC1 || type != CV_8UC2 || type != CV_8UC4 )
return false;
int templateWindowHalfWize = templateWindowSize / 2;
virtual void generateTestData()
{
+ Mat image;
+ if (cn == 1)
+ {
+ image = readImage("denoising/lena_noised_gaussian_sigma=10.png", IMREAD_GRAYSCALE);
+ ASSERT_FALSE(image.empty());
+ }
+
const int type = CV_8UC(cn);
- Size roiSize = randomSize(1, MAX_VALUE);
+ Size roiSize = cn == 1 ? image.size() : randomSize(1, MAX_VALUE);
Border srcBorder = randomBorder(0, use_roi ? MAX_VALUE : 0);
randomSubMat(src, src_roi, roiSize, srcBorder, type, 0, 255);
+ if (cn == 1)
+ image.copyTo(src_roi);
Border dstBorder = randomBorder(0, use_roi ? MAX_VALUE : 0);
randomSubMat(dst, dst_roi, roiSize, dstBorder, type, 0, 255);