Skip to content

Commit 051759c

Browse files
committed
Merge pull request #382 from zhou-chao:l0smooth
2 parents 752e2a5 + e4c78ef commit 051759c

File tree

5 files changed

+617
-0
lines changed

5 files changed

+617
-0
lines changed

modules/ximgproc/doc/ximgproc.bib

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,18 @@ @inproceedings{Farbman2008
8989
organization={ACM}
9090
}
9191

92+
93+
@inproceedings{xu2011image,
94+
title={Image smoothing via L 0 gradient minimization},
95+
author={Xu, Li and Lu, Cewu and Xu, Yi and Jia, Jiaya},
96+
booktitle={ACM Transactions on Graphics (TOG)},
97+
volume={30},
98+
number={6},
99+
pages={174},
100+
year={2011},
101+
organization={ACM}
102+
}
103+
92104
@inproceedings{Revaud2015,
93105
title={EpicFlow: Edge-Preserving Interpolation of Correspondences for Optical Flow},
94106
author={Revaud, Jerome and Weinzaepfel, Philippe and Harchaoui, Zaid and Schmid, Cordelia},

modules/ximgproc/include/opencv2/ximgproc/edge_filter.hpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,19 @@ it should be 0.25. Setting it to 1.0 may lead to streaking artifacts.
378378
*/
379379
CV_EXPORTS_W void fastGlobalSmootherFilter(InputArray guide, InputArray src, OutputArray dst, double lambda, double sigma_color, double lambda_attenuation=0.25, int num_iter=3);
380380

381+
/** @brief Global image smoothing via L0 gradient minimization.
382+
383+
@param src source image for filtering with unsigned 8-bit or signed 16-bit or floating-point depth.
384+
385+
@param dst destination image.
386+
387+
@param lambda parameter defining the smooth term weight.
388+
389+
@param kappa parameter defining the increasing factor of the weight of the gradient data term.
390+
391+
For more details about L0 Smoother, see the original paper @cite xu2011image.
392+
*/
393+
CV_EXPORTS_W void l0Smooth(InputArray src, OutputArray dst, double lambda = 0.02, double kappa = 2.0);
381394
//! @}
382395
}
383396
}
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
/*
2+
* By downloading, copying, installing or using the software you agree to this license.
3+
* If you do not agree to this license, do not download, install,
4+
* copy or use the software.
5+
*
6+
*
7+
* License Agreement
8+
* For Open Source Computer Vision Library
9+
* (3 - clause BSD License)
10+
*
11+
* Redistribution and use in source and binary forms, with or without modification,
12+
* are permitted provided that the following conditions are met :
13+
*
14+
* *Redistributions of source code must retain the above copyright notice,
15+
* this list of conditions and the following disclaimer.
16+
*
17+
* * Redistributions in binary form must reproduce the above copyright notice,
18+
* this list of conditions and the following disclaimer in the documentation
19+
* and / or other materials provided with the distribution.
20+
*
21+
* * Neither the names of the copyright holders nor the names of the contributors
22+
* may be used to endorse or promote products derived from this software
23+
* without specific prior written permission.
24+
*
25+
* This software is provided by the copyright holders and contributors "as is" and
26+
* any express or implied warranties, including, but not limited to, the implied
27+
* warranties of merchantability and fitness for a particular purpose are disclaimed.
28+
* In no event shall copyright holders or contributors be liable for any direct,
29+
* indirect, incidental, special, exemplary, or consequential damages
30+
* (including, but not limited to, procurement of substitute goods or services;
31+
* loss of use, data, or profits; or business interruption) however caused
32+
* and on any theory of liability, whether in contract, strict liability,
33+
* or tort(including negligence or otherwise) arising in any way out of
34+
* the use of this software, even if advised of the possibility of such damage.
35+
*/
36+
37+
#include "perf_precomp.hpp"
38+
39+
namespace cvtest
40+
{
41+
42+
using std::tr1::tuple;
43+
using std::tr1::get;
44+
using namespace perf;
45+
using namespace testing;
46+
using namespace cv;
47+
using namespace cv::ximgproc;
48+
49+
typedef tuple<Size, MatType, int> L0SmoothTestParam;
50+
typedef TestBaseWithParam<L0SmoothTestParam> L0SmoothTest;
51+
52+
PERF_TEST_P(L0SmoothTest, perf,
53+
Combine(
54+
SZ_TYPICAL,
55+
Values(CV_8U, CV_16U, CV_32F, CV_64F),
56+
Values(1, 3))
57+
)
58+
{
59+
L0SmoothTestParam params = GetParam();
60+
Size sz = get<0>(params);
61+
int depth = get<1>(params);
62+
int srcCn = get<2>(params);
63+
64+
Mat src(sz, CV_MAKE_TYPE(depth, srcCn));
65+
Mat dst(sz, src.type());
66+
67+
cv::setNumThreads(cv::getNumberOfCPUs());
68+
declare.in(src, WARMUP_RNG).out(dst).tbb_threads(cv::getNumberOfCPUs());
69+
70+
RNG rnd(sz.height + depth + srcCn);
71+
double lambda = rnd.uniform(0.01, 0.05);
72+
double kappa = rnd.uniform(1.0, 3.0);
73+
74+
TEST_CYCLE_N(1)
75+
{
76+
l0Smooth(src, dst, lambda, kappa);
77+
}
78+
79+
SANITY_CHECK_NOTHING();
80+
}
81+
}

0 commit comments

Comments
 (0)