1 /*M///////////////////////////////////////////////////////////////////////////////////////
3 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
5 // By downloading, copying, installing or using the software you agree to this license.
6 // If you do not agree to this license, do not download, install,
7 // copy or use the software.
11 // For Open Source Computer Vision Library
13 // Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
14 // Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
15 // Third party copyrights are property of their respective owners.
18 // Fangfang Bai, fangfang@multicorewareinc.com
19 // Jin Ma, jin@multicorewareinc.com
21 // Redistribution and use in source and binary forms, with or without modification,
22 // are permitted provided that the following conditions are met:
24 // * Redistribution's of source code must retain the above copyright notice,
25 // this list of conditions and the following disclaimer.
27 // * Redistribution's in binary form must reproduce the above copyright notice,
28 // this list of conditions and the following disclaimer in the documentation
29 // and/or other oclMaterials provided with the distribution.
31 // * The name of the copyright holders may not be used to endorse or promote products
32 // derived from this software without specific prior written permission.
34 // This software is provided by the copyright holders and contributors as is and
35 // any express or implied warranties, including, but not limited to, the implied
36 // warranties of merchantability and fitness for a particular purpose are disclaimed.
37 // In no event shall the Intel Corporation or contributors be liable for any direct,
38 // indirect, incidental, special, exemplary, or consequential damages
39 // (including, but not limited to, procurement of substitute goods or services;
40 // loss of use, data, or profits; or business interruption) however caused
41 // and on any theory of liability, whether in contract, strict liability,
42 // or tort (including negligence or otherwise) arising in any way out of
43 // the use of this software, even if advised of the possibility of such damage.
46 #include "precomp.hpp"
48 ///////////// equalizeHist ////////////////////////
49 PERFTEST(equalizeHist)
51 Mat src, dst, ocl_dst;
52 int all_type[] = {CV_8UC1};
53 std::string type_name[] = {"CV_8UC1"};
55 for (int size = Min_Size; size <= Max_Size; size *= Multiple)
57 for (size_t j = 0; j < sizeof(all_type) / sizeof(int); j++)
59 SUBTEST << size << 'x' << size << "; " << type_name[j] ;
61 gen(src, size, size, all_type[j], 0, 256);
63 equalizeHist(src, dst);
66 equalizeHist(src, dst);
69 ocl::oclMat d_src(src);
75 ocl::equalizeHist(d_src, d_dst);
79 ocl::equalizeHist(d_src, d_dst);
84 ocl::equalizeHist(d_src, d_dst);
85 d_dst.download(ocl_dst);
88 TestSystem::instance().ExpectedMatNear(dst, ocl_dst, 1.1);
93 /////////// CopyMakeBorder //////////////////////
94 PERFTEST(CopyMakeBorder)
96 Mat src, dst, ocl_dst;
99 int bordertype = BORDER_CONSTANT;
100 int all_type[] = {CV_8UC1, CV_8UC4};
101 std::string type_name[] = {"CV_8UC1", "CV_8UC4"};
103 for (int size = Min_Size; size <= Max_Size; size *= Multiple)
105 for (size_t j = 0; j < sizeof(all_type) / sizeof(int); j++)
107 SUBTEST << size << 'x' << size << "; " << type_name[j] ;
110 gen(src, size, size, all_type[j], 0, 256);
112 copyMakeBorder(src, dst, 7, 5, 5, 7, bordertype, cv::Scalar(1.0));
115 copyMakeBorder(src, dst, 7, 5, 5, 7, bordertype, cv::Scalar(1.0));
118 ocl::oclMat d_src(src);
121 ocl::copyMakeBorder(d_src, d_dst, 7, 5, 5, 7, bordertype, cv::Scalar(1.0));
125 ocl::copyMakeBorder(d_src, d_dst, 7, 5, 5, 7, bordertype, cv::Scalar(1.0));
130 ocl::copyMakeBorder(d_src, d_dst, 7, 5, 5, 7, bordertype, cv::Scalar(1.0));
131 d_dst.download(ocl_dst);
134 TestSystem::instance().ExpectedMatNear(dst, ocl_dst, 0.0);
139 ///////////// cornerMinEigenVal ////////////////////////
140 PERFTEST(cornerMinEigenVal)
142 Mat src, dst, ocl_dst;
145 int blockSize = 7, apertureSize = 1 + 2 * (rand() % 4);
146 int borderType = BORDER_REFLECT;
147 int all_type[] = {CV_8UC1, CV_32FC1};
148 std::string type_name[] = {"CV_8UC1", "CV_32FC1"};
150 for (int size = Min_Size; size <= Max_Size; size *= Multiple)
152 for (size_t j = 0; j < sizeof(all_type) / sizeof(int); j++)
154 SUBTEST << size << 'x' << size << "; " << type_name[j] ;
156 gen(src, size, size, all_type[j], 0, 256);
158 cornerMinEigenVal(src, dst, blockSize, apertureSize, borderType);
161 cornerMinEigenVal(src, dst, blockSize, apertureSize, borderType);
164 ocl::oclMat d_src(src);
167 ocl::cornerMinEigenVal(d_src, d_dst, blockSize, apertureSize, borderType);
171 ocl::cornerMinEigenVal(d_src, d_dst, blockSize, apertureSize, borderType);
176 ocl::cornerMinEigenVal(d_src, d_dst, blockSize, apertureSize, borderType);
177 d_dst.download(ocl_dst);
180 TestSystem::instance().ExpectedMatNear(dst, ocl_dst, 1.0);
185 ///////////// cornerHarris ////////////////////////
186 PERFTEST(cornerHarris)
188 Mat src, dst, ocl_dst;
189 ocl::oclMat d_src, d_dst;
191 int all_type[] = {CV_8UC1, CV_32FC1};
192 std::string type_name[] = {"CV_8UC1", "CV_32FC1"};
194 for (int size = Min_Size; size <= Max_Size; size *= Multiple)
196 for (size_t j = 0; j < sizeof(all_type) / sizeof(int); j++)
198 SUBTEST << size << 'x' << size << "; " << type_name[j] << " ; BORDER_REFLECT";
200 gen(src, size, size, all_type[j], 0, 1);
202 cornerHarris(src, dst, 5, 7, 0.1, BORDER_REFLECT);
205 cornerHarris(src, dst, 5, 7, 0.1, BORDER_REFLECT);
211 ocl::cornerHarris(d_src, d_dst, 5, 7, 0.1, BORDER_REFLECT);
215 ocl::cornerHarris(d_src, d_dst, 5, 7, 0.1, BORDER_REFLECT);
220 ocl::cornerHarris(d_src, d_dst, 5, 7, 0.1, BORDER_REFLECT);
221 d_dst.download(ocl_dst);
224 TestSystem::instance().ExpectedMatNear(dst, ocl_dst, 1.0);
230 ///////////// integral ////////////////////////
233 Mat src, sum, ocl_sum;
234 ocl::oclMat d_src, d_sum, d_buf;
236 int all_type[] = {CV_8UC1};
237 std::string type_name[] = {"CV_8UC1"};
239 for (int size = Min_Size; size <= Max_Size; size *= Multiple)
241 for (size_t j = 0; j < sizeof(all_type) / sizeof(int); j++)
243 SUBTEST << size << 'x' << size << "; " << type_name[j] ;
245 gen(src, size, size, all_type[j], 0, 256);
256 ocl::integral(d_src, d_sum);
260 ocl::integral(d_src, d_sum);
265 ocl::integral(d_src, d_sum);
266 d_sum.download(ocl_sum);
269 if(sum.type() == ocl_sum.type()) //we won't test accuracy when cpu function overlow
270 TestSystem::instance().ExpectedMatNear(sum, ocl_sum, 0.0);
276 ///////////// WarpAffine ////////////////////////
279 Mat src, dst, ocl_dst;
280 ocl::oclMat d_src, d_dst;
282 static const double coeffs[2][3] =
284 {cos(CV_PI / 6), -sin(CV_PI / 6), 100.0},
285 {sin(CV_PI / 6), cos(CV_PI / 6), -100.0}
287 Mat M(2, 3, CV_64F, (void *)coeffs);
288 int interpolation = INTER_NEAREST;
290 int all_type[] = {CV_8UC1, CV_8UC4};
291 std::string type_name[] = {"CV_8UC1", "CV_8UC4"};
294 for (int size = Min_Size; size <= Max_Size; size *= Multiple)
296 for (size_t j = 0; j < sizeof(all_type) / sizeof(int); j++)
298 SUBTEST << size << 'x' << size << "; " << type_name[j] ;
300 gen(src, size, size, all_type[j], 0, 256);
301 gen(dst, size, size, all_type[j], 0, 256);
302 Size size1 = Size(size, size);
304 warpAffine(src, dst, M, size1, interpolation);
307 warpAffine(src, dst, M, size1, interpolation);
313 ocl::warpAffine(d_src, d_dst, M, size1, interpolation);
317 ocl::warpAffine(d_src, d_dst, M, size1, interpolation);
322 ocl::warpAffine(d_src, d_dst, M, size1, interpolation);
323 d_dst.download(ocl_dst);
326 TestSystem::instance().ExpectedMatNear(dst, ocl_dst, 1.0);
331 ///////////// WarpPerspective ////////////////////////
332 PERFTEST(WarpPerspective)
334 Mat src, dst, ocl_dst;
335 ocl::oclMat d_src, d_dst;
337 static const double coeffs[3][3] =
339 {cos(CV_PI / 6), -sin(CV_PI / 6), 100.0},
340 {sin(CV_PI / 6), cos(CV_PI / 6), -100.0},
343 Mat M(3, 3, CV_64F, (void *)coeffs);
344 int interpolation = INTER_LINEAR;
346 int all_type[] = {CV_8UC1, CV_8UC4};
347 std::string type_name[] = {"CV_8UC1", "CV_8UC4"};
349 for (int size = Min_Size; size <= Max_Size; size *= Multiple)
351 for (size_t j = 0; j < sizeof(all_type) / sizeof(int); j++)
353 SUBTEST << size << 'x' << size << "; " << type_name[j] ;
355 gen(src, size, size, all_type[j], 0, 256);
356 gen(dst, size, size, all_type[j], 0, 256);
357 Size size1 = Size(size, size);
359 warpPerspective(src, dst, M, size1, interpolation);
362 warpPerspective(src, dst, M, size1, interpolation);
368 ocl::warpPerspective(d_src, d_dst, M, size1, interpolation);
372 ocl::warpPerspective(d_src, d_dst, M, size1, interpolation);
377 ocl::warpPerspective(d_src, d_dst, M, size1, interpolation);
378 d_dst.download(ocl_dst);
381 TestSystem::instance().ExpectedMatNear(dst, ocl_dst, 1.0);
387 ///////////// resize ////////////////////////
390 Mat src, dst, ocl_dst;
391 ocl::oclMat d_src, d_dst;
394 int all_type[] = {CV_8UC1, CV_8UC4};
395 std::string type_name[] = {"CV_8UC1", "CV_8UC4"};
397 for (int size = Min_Size; size <= Max_Size; size *= Multiple)
399 for (size_t j = 0; j < sizeof(all_type) / sizeof(int); j++)
401 SUBTEST << size << 'x' << size << "; " << type_name[j] << " ; up";
403 gen(src, size, size, all_type[j], 0, 256);
405 resize(src, dst, Size(), 2.0, 2.0);
408 resize(src, dst, Size(), 2.0, 2.0);
414 ocl::resize(d_src, d_dst, Size(), 2.0, 2.0);
418 ocl::resize(d_src, d_dst, Size(), 2.0, 2.0);
423 ocl::resize(d_src, d_dst, Size(), 2.0, 2.0);
424 d_dst.download(ocl_dst);
427 TestSystem::instance().ExpectedMatNear(dst, ocl_dst, 1.0);
432 for (int size = Min_Size; size <= Max_Size; size *= Multiple)
434 for (size_t j = 0; j < sizeof(all_type) / sizeof(int); j++)
436 SUBTEST << size << 'x' << size << "; " << type_name[j] << " ; down";
438 gen(src, size, size, all_type[j], 0, 256);
440 resize(src, dst, Size(), 0.5, 0.5);
443 resize(src, dst, Size(), 0.5, 0.5);
449 ocl::resize(d_src, d_dst, Size(), 0.5, 0.5);
453 ocl::resize(d_src, d_dst, Size(), 0.5, 0.5);
458 ocl::resize(d_src, d_dst, Size(), 0.5, 0.5);
459 d_dst.download(ocl_dst);
462 TestSystem::instance().ExpectedMatNear(dst, ocl_dst, 1.0);
467 ///////////// threshold////////////////////////
470 Mat src, dst, ocl_dst;
471 ocl::oclMat d_src, d_dst;
473 for (int size = Min_Size; size <= Max_Size; size *= Multiple)
475 SUBTEST << size << 'x' << size << "; 8UC1; THRESH_BINARY";
477 gen(src, size, size, CV_8U, 0, 100);
479 threshold(src, dst, 50.0, 0.0, THRESH_BINARY);
482 threshold(src, dst, 50.0, 0.0, THRESH_BINARY);
488 ocl::threshold(d_src, d_dst, 50.0, 0.0, THRESH_BINARY);
492 ocl::threshold(d_src, d_dst, 50.0, 0.0, THRESH_BINARY);
497 ocl::threshold(d_src, d_dst, 50.0, 0.0, THRESH_BINARY);
498 d_dst.download(ocl_dst);
501 TestSystem::instance().ExpectedMatNear(dst, ocl_dst, 1.0);
504 for (int size = Min_Size; size <= Max_Size; size *= Multiple)
506 SUBTEST << size << 'x' << size << "; 32FC1; THRESH_TRUNC [NPP]";
508 gen(src, size, size, CV_32FC1, 0, 100);
510 threshold(src, dst, 50.0, 0.0, THRESH_TRUNC);
513 threshold(src, dst, 50.0, 0.0, THRESH_TRUNC);
519 ocl::threshold(d_src, d_dst, 50.0, 0.0, THRESH_TRUNC);
523 ocl::threshold(d_src, d_dst, 50.0, 0.0, THRESH_TRUNC);
528 ocl::threshold(d_src, d_dst, 50.0, 0.0, THRESH_TRUNC);
529 d_dst.download(ocl_dst);
532 TestSystem::instance().ExpectedMatNear(dst, ocl_dst, 1.0);
535 ///////////// meanShiftFiltering////////////////////////
536 COOR do_meanShift(int x0, int y0, uchar *sptr, uchar *dptr, int sstep, cv::Size size, int sp, int sr, int maxIter, float eps, int *tab)
543 uchar *pstart = NULL;
544 int revx = 0, revy = 0;
549 // iterate meanshift procedure
550 for(iter = 0; iter < maxIter; iter++ )
553 int s0 = 0, s1 = 0, s2 = 0, sx = 0, sy = 0;
555 //mean shift: process pixels in window (p-sigmaSp)x(p+sigmaSp)
561 //deal with the image boundary
562 if(minx < 0) minx = 0;
563 if(miny < 0) miny = 0;
564 if(maxx >= size.width) maxx = size.width - 1;
565 if(maxy >= size.height) maxy = size.height - 1;
572 pstart = pstart + revy * sstep + (revx << 2); //point to the new position
575 ptr = ptr + (miny - y0) * sstep + ((minx - x0) << 2); //point to the start in the row
577 for( int y = miny; y <= maxy; y++, ptr += sstep - ((maxx - minx + 1) << 2))
581 #if CV_ENABLE_UNROLLED
582 for( ; x + 4 <= maxx; x += 4, ptr += 16)
585 t0 = ptr[0], t1 = ptr[1], t2 = ptr[2];
586 if(tab[t0 - c0 + 255] + tab[t1 - c1 + 255] + tab[t2 - c2 + 255] <= isr2)
594 t0 = ptr[4], t1 = ptr[5], t2 = ptr[6];
595 if(tab[t0 - c0 + 255] + tab[t1 - c1 + 255] + tab[t2 - c2 + 255] <= isr2)
603 t0 = ptr[8], t1 = ptr[9], t2 = ptr[10];
604 if(tab[t0 - c0 + 255] + tab[t1 - c1 + 255] + tab[t2 - c2 + 255] <= isr2)
612 t0 = ptr[12], t1 = ptr[13], t2 = ptr[14];
613 if(tab[t0 - c0 + 255] + tab[t1 - c1 + 255] + tab[t2 - c2 + 255] <= isr2)
623 for(; x <= maxx; x++, ptr += 4)
625 int t0 = ptr[0], t1 = ptr[1], t2 = ptr[2];
626 if(tab[t0 - c0 + 255] + tab[t1 - c1 + 255] + tab[t2 - c2 + 255] <= isr2)
650 bool stopFlag = (x0 == x1 && y0 == y1) || (abs(x1 - x0) + abs(y1 - y0) +
651 tab[s0 - c0 + 255] + tab[s1 - c1 + 255] + tab[s2 - c2 + 255] <= eps);
653 //revise the pointer corresponding to the new (y0,x0)
673 coor.x = static_cast<short>(x0);
674 coor.y = static_cast<short>(y0);
678 static void meanShiftFiltering_(const Mat &src_roi, Mat &dst_roi, int sp, int sr, cv::TermCriteria crit)
680 if( src_roi.empty() )
681 CV_Error( CV_StsBadArg, "The input image is empty" );
683 if( src_roi.depth() != CV_8U || src_roi.channels() != 4 )
684 CV_Error( CV_StsUnsupportedFormat, "Only 8-bit, 4-channel images are supported" );
686 dst_roi.create(src_roi.size(), src_roi.type());
688 CV_Assert( (src_roi.cols == dst_roi.cols) && (src_roi.rows == dst_roi.rows) );
689 CV_Assert( !(dst_roi.step & 0x3) );
691 if( !(crit.type & cv::TermCriteria::MAX_ITER) )
693 int maxIter = std::min(std::max(crit.maxCount, 1), 100);
695 if( !(crit.type & cv::TermCriteria::EPS) )
697 eps = (float)std::max(crit.epsilon, 0.0);
700 for(int i = 0; i < 512; i++)
701 tab[i] = (i - 255) * (i - 255);
702 uchar *sptr = src_roi.data;
703 uchar *dptr = dst_roi.data;
704 int sstep = (int)src_roi.step;
705 int dstep = (int)dst_roi.step;
706 cv::Size size = src_roi.size();
708 for(int i = 0; i < size.height; i++, sptr += sstep - (size.width << 2),
709 dptr += dstep - (size.width << 2))
711 for(int j = 0; j < size.width; j++, sptr += 4, dptr += 4)
713 do_meanShift(j, i, sptr, dptr, sstep, size, sp, sr, maxIter, eps, tab);
718 PERFTEST(meanShiftFiltering)
721 Mat src, dst, ocl_dst;
723 ocl::oclMat d_src, d_dst;
725 for (int size = Min_Size; size <= Max_Size; size *= Multiple)
727 SUBTEST << size << 'x' << size << "; 8UC3 vs 8UC4";
729 gen(src, size, size, CV_8UC4, Scalar::all(0), Scalar::all(256));
731 cv::TermCriteria crit(cv::TermCriteria::COUNT + cv::TermCriteria::EPS, 5, 1);
733 meanShiftFiltering_(src, dst, sp, sr, crit);
736 meanShiftFiltering_(src, dst, sp, sr, crit);
742 ocl::meanShiftFiltering(d_src, d_dst, sp, sr, crit);
746 ocl::meanShiftFiltering(d_src, d_dst, sp, sr);
751 ocl::meanShiftFiltering(d_src, d_dst, sp, sr);
752 d_dst.download(ocl_dst);
755 TestSystem::instance().ExpectedMatNear(dst, ocl_dst, 0.0);
759 void meanShiftProc_(const Mat &src_roi, Mat &dst_roi, Mat &dstCoor_roi, int sp, int sr, cv::TermCriteria crit)
763 CV_Error(CV_StsBadArg, "The input image is empty");
765 if (src_roi.depth() != CV_8U || src_roi.channels() != 4)
767 CV_Error(CV_StsUnsupportedFormat, "Only 8-bit, 4-channel images are supported");
770 dst_roi.create(src_roi.size(), src_roi.type());
771 dstCoor_roi.create(src_roi.size(), CV_16SC2);
773 CV_Assert((src_roi.cols == dst_roi.cols) && (src_roi.rows == dst_roi.rows) &&
774 (src_roi.cols == dstCoor_roi.cols) && (src_roi.rows == dstCoor_roi.rows));
775 CV_Assert(!(dstCoor_roi.step & 0x3));
777 if (!(crit.type & cv::TermCriteria::MAX_ITER))
782 int maxIter = std::min(std::max(crit.maxCount, 1), 100);
785 if (!(crit.type & cv::TermCriteria::EPS))
790 eps = (float)std::max(crit.epsilon, 0.0);
794 for (int i = 0; i < 512; i++)
796 tab[i] = (i - 255) * (i - 255);
799 uchar *sptr = src_roi.data;
800 uchar *dptr = dst_roi.data;
801 short *dCoorptr = (short *)dstCoor_roi.data;
802 int sstep = (int)src_roi.step;
803 int dstep = (int)dst_roi.step;
804 int dCoorstep = (int)dstCoor_roi.step >> 1;
805 cv::Size size = src_roi.size();
807 for (int i = 0; i < size.height; i++, sptr += sstep - (size.width << 2),
808 dptr += dstep - (size.width << 2), dCoorptr += dCoorstep - (size.width << 1))
810 for (int j = 0; j < size.width; j++, sptr += 4, dptr += 4, dCoorptr += 2)
812 *((COOR *)dCoorptr) = do_meanShift(j, i, sptr, dptr, sstep, size, sp, sr, maxIter, eps, tab);
817 PERFTEST(meanShiftProc)
820 vector<Mat> dst(2), ocl_dst(2);
821 ocl::oclMat d_src, d_dst, d_dstCoor;
823 TermCriteria crit(TermCriteria::COUNT + TermCriteria::EPS, 5, 1);
825 for (int size = Min_Size; size <= Max_Size; size *= Multiple)
827 SUBTEST << size << 'x' << size << "; 8UC4 and CV_16SC2 ";
829 gen(src, size, size, CV_8UC4, Scalar::all(0), Scalar::all(256));
831 meanShiftProc_(src, dst[0], dst[1], 5, 6, crit);
834 meanShiftProc_(src, dst[0], dst[1], 5, 6, crit);
840 ocl::meanShiftProc(d_src, d_dst, d_dstCoor, 5, 6, crit);
844 ocl::meanShiftProc(d_src, d_dst, d_dstCoor, 5, 6, crit);
849 ocl::meanShiftProc(d_src, d_dst, d_dstCoor, 5, 6, crit);
850 d_dst.download(ocl_dst[0]);
851 d_dstCoor.download(ocl_dst[1]);
854 vector<double> eps(2, 0.);
855 TestSystem::instance().ExpectMatsNear(dst, ocl_dst, eps);
859 ///////////// remap////////////////////////
862 Mat src, dst, xmap, ymap, ocl_dst;
863 ocl::oclMat d_src, d_dst, d_xmap, d_ymap;
865 int all_type[] = {CV_8UC1, CV_8UC4};
866 std::string type_name[] = {"CV_8UC1", "CV_8UC4"};
868 int interpolation = INTER_LINEAR;
869 int borderMode = BORDER_CONSTANT;
871 for (int size = Min_Size; size <= Max_Size; size *= Multiple)
873 for (size_t t = 0; t < sizeof(all_type) / sizeof(int); t++)
875 SUBTEST << size << 'x' << size << "; src " << type_name[t] << "; map CV_32FC1";
877 gen(src, size, size, all_type[t], 0, 256);
879 xmap.create(size, size, CV_32FC1);
880 dst.create(size, size, CV_32FC1);
881 ymap.create(size, size, CV_32FC1);
883 for (int i = 0; i < size; ++i)
885 float *xmap_row = xmap.ptr<float>(i);
886 float *ymap_row = ymap.ptr<float>(i);
888 for (int j = 0; j < size; ++j)
890 xmap_row[j] = (j - size * 0.5f) * 0.75f + size * 0.5f;
891 ymap_row[j] = (i - size * 0.5f) * 0.75f + size * 0.5f;
895 remap(src, dst, xmap, ymap, interpolation, borderMode);
898 remap(src, dst, xmap, ymap, interpolation, borderMode);
907 ocl::remap(d_src, d_dst, d_xmap, d_ymap, interpolation, borderMode);
911 ocl::remap(d_src, d_dst, d_xmap, d_ymap, interpolation, borderMode);
916 ocl::remap(d_src, d_dst, d_xmap, d_ymap, interpolation, borderMode);
917 d_dst.download(ocl_dst);
920 TestSystem::instance().ExpectedMatNear(dst, ocl_dst, 2.0);
925 ///////////// CLAHE ////////////////////////
928 Mat src, dst, ocl_dst;
929 cv::ocl::oclMat d_src, d_dst;
930 int all_type[] = {CV_8UC1};
931 std::string type_name[] = {"CV_8UC1"};
933 double clipLimit = 40.0;
935 cv::Ptr<cv::CLAHE> clahe = cv::createCLAHE(clipLimit);
936 cv::Ptr<cv::ocl::CLAHE> d_clahe = cv::ocl::createCLAHE(clipLimit);
938 for (int size = Min_Size; size <= Max_Size; size *= Multiple)
940 for (size_t j = 0; j < sizeof(all_type) / sizeof(int); j++)
942 SUBTEST << size << 'x' << size << "; " << type_name[j] ;
944 gen(src, size, size, all_type[j], 0, 256);
947 clahe->apply(src, dst);
953 d_clahe->apply(d_src, d_dst);
958 TestSystem::instance().ExpectedMatNear(dst, ocl_dst, 1.0);
961 d_clahe->apply(d_src, d_dst);
966 d_clahe->apply(d_src, d_dst);