Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv_contrib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv_contrib
Commits
7b2c6f83
Commit
7b2c6f83
authored
Feb 15, 2016
by
Maksim Shabunin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #375 from zhou-chao:wmfv3
parents
a29ec8a1
88379486
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
311 additions
and
0 deletions
+311
-0
ximgproc.bib
modules/ximgproc/doc/ximgproc.bib
+18
-0
ximgproc.hpp
modules/ximgproc/include/opencv2/ximgproc.hpp
+1
-0
edge_filter.hpp
modules/ximgproc/include/opencv2/ximgproc/edge_filter.hpp
+2
-0
weighted_median_filter.hpp
...gproc/include/opencv2/ximgproc/weighted_median_filter.hpp
+95
-0
perf_weighted_median_filter.cpp
modules/ximgproc/perf/perf_weighted_median_filter.cpp
+88
-0
weighted_median_filter.cpp
modules/ximgproc/src/weighted_median_filter.cpp
+0
-0
test_weighted_median_filter.cpp
modules/ximgproc/test/test_weighted_median_filter.cpp
+107
-0
No files found.
modules/ximgproc/doc/ximgproc.bib
View file @
7b2c6f83
...
...
@@ -148,3 +148,21 @@
month = {June},
year = {2015}
}
@incollection{zhang2014rolling,
title={Rolling guidance filter},
author={Zhang, Qi and Shen, Xiaoyong and Xu, Li and Jia, Jiaya},
booktitle={Computer Vision--ECCV 2014},
pages={815--830},
year={2014},
publisher={Springer}
}
@inproceedings{zhang2014100+,
title={100+ times faster weighted median filter (WMF)},
author={Zhang, Qi and Xu, Li and Jia, Jiaya},
booktitle={Computer Vision and Pattern Recognition (CVPR), 2014 IEEE Conference on},
pages={2830--2837},
year={2014},
organization={IEEE}
}
modules/ximgproc/include/opencv2/ximgproc.hpp
View file @
7b2c6f83
...
...
@@ -45,6 +45,7 @@
#include "ximgproc/segmentation.hpp"
#include "ximgproc/fast_hough_transform.hpp"
#include "ximgproc/estimated_covariance.hpp"
#include "ximgproc/weighted_median_filter.hpp"
#include "ximgproc/slic.hpp"
#include "ximgproc/lsc.hpp"
...
...
modules/ximgproc/include/opencv2/ximgproc/edge_filter.hpp
View file @
7b2c6f83
...
...
@@ -321,6 +321,8 @@ void jointBilateralFilter(InputArray joint, InputArray src, OutputArray dst, int
/** @brief Applies the rolling guidance filter to an image.
For more details, please see @cite zhang2014rolling
@param src Source 8-bit or floating-point, 1-channel or 3-channel image.
@param dst Destination image of the same size and type as src.
...
...
modules/ximgproc/include/opencv2/ximgproc/weighted_median_filter.hpp
0 → 100644
View file @
7b2c6f83
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2015, The Chinese University of Hong Kong, all rights reserved.
//
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#ifndef __OPENCV_WEIGHTED_MEDIAN_FILTER_HPP__
#define __OPENCV_WEIGHTED_MEDIAN_FILTER_HPP__
#ifdef __cplusplus
/**
* @file
* @date Sept 9, 2015
* @author Zhou Chao
*/
#include <opencv2/core.hpp>
#include <string>
namespace
cv
{
namespace
ximgproc
{
/**
* @brief Specifies weight types of weighted median filter.
*/
enum
WMFWeightType
{
WMF_EXP
,
//!< \f$exp(-|I1-I2|^2/(2*sigma^2))\f$
WMF_IV1
,
//!< \f$(|I1-I2|+sigma)^-1\f$
WMF_IV2
,
//!< \f$(|I1-I2|^2+sigma^2)^-1\f$
WMF_COS
,
//!< \f$dot(I1,I2)/(|I1|*|I2|)\f$
WMF_JAC
,
//!< \f$(min(r1,r2)+min(g1,g2)+min(b1,b2))/(max(r1,r2)+max(g1,g2)+max(b1,b2))\f$
WMF_OFF
//!< unweighted
};
/**
* @brief Applies weighted median filter to an image.
*
* For more details about this implementation, please see @cite zhang2014100+
*
* @param joint Joint 8-bit, 1-channel or 3-channel image.
* @param src Source 8-bit or floating-point, 1-channel or 3-channel image.
* @param dst Destination image.
* @param r Radius of filtering kernel, should be a positive integer.
* @param sigma Filter range standard deviation for the joint image.
* @param weightType weightType The type of weight definition, see WMFWeightType
* @param mask A 0-1 mask that has the same size with I. This mask is used to ignore the effect of some pixels. If the pixel value on mask is 0,
* the pixel will be ignored when maintaining the joint-histogram. This is useful for applications like optical flow occlusion handling.
*
* @sa medianBlur, jointBilateralFilter
*/
CV_EXPORTS
void
weightedMedianFilter
(
InputArray
joint
,
InputArray
src
,
OutputArray
dst
,
int
r
,
double
sigma
=
25.5
,
WMFWeightType
weightType
=
WMF_EXP
,
Mat
mask
=
Mat
());
}
}
#endif
#endif
modules/ximgproc/perf/perf_weighted_median_filter.cpp
0 → 100644
View file @
7b2c6f83
/*
* By downloading, copying, installing or using the software you agree to this license.
* If you do not agree to this license, do not download, install,
* copy or use the software.
*
*
* License Agreement
* For Open Source Computer Vision Library
* (3 - clause BSD License)
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met :
*
* *Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and / or other materials provided with the distribution.
*
* * Neither the names of the copyright holders nor the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided by the copyright holders and contributors "as is" and
* any express or implied warranties, including, but not limited to, the implied
* warranties of merchantability and fitness for a particular purpose are disclaimed.
* In no event shall copyright holders or contributors be liable for any direct,
* indirect, incidental, special, exemplary, or consequential damages
* (including, but not limited to, procurement of substitute goods or services;
* loss of use, data, or profits; or business interruption) however caused
* and on any theory of liability, whether in contract, strict liability,
* or tort(including negligence or otherwise) arising in any way out of
* the use of this software, even if advised of the possibility of such damage.
*/
#include "perf_precomp.hpp"
namespace
cvtest
{
using
std
::
tr1
::
tuple
;
using
std
::
tr1
::
get
;
using
namespace
perf
;
using
namespace
testing
;
using
namespace
cv
;
using
namespace
cv
::
ximgproc
;
typedef
tuple
<
Size
,
MatType
,
int
,
int
,
int
,
WMFWeightType
>
WMFTestParam
;
typedef
TestBaseWithParam
<
WMFTestParam
>
WeightedMedianFilterTest
;
PERF_TEST_P
(
WeightedMedianFilterTest
,
perf
,
Combine
(
Values
(
szODD
,
szQVGA
),
Values
(
CV_8U
,
CV_32F
),
Values
(
1
,
3
),
Values
(
1
,
3
),
Values
(
3
,
5
),
Values
(
WMF_EXP
,
WMF_COS
))
)
{
RNG
rnd
(
1
);
WMFTestParam
params
=
GetParam
();
double
sigma
=
rnd
.
uniform
(
20.0
,
30.0
);
Size
sz
=
get
<
0
>
(
params
);
int
srcDepth
=
get
<
1
>
(
params
);
int
jCn
=
get
<
2
>
(
params
);
int
srcCn
=
get
<
3
>
(
params
);
int
r
=
get
<
4
>
(
params
);
WMFWeightType
weightType
=
get
<
5
>
(
params
);
Mat
joint
(
sz
,
CV_MAKE_TYPE
(
CV_8U
,
jCn
));
Mat
src
(
sz
,
CV_MAKE_TYPE
(
srcDepth
,
srcCn
));
Mat
dst
(
sz
,
src
.
type
());
cv
::
setNumThreads
(
cv
::
getNumberOfCPUs
());
declare
.
in
(
joint
,
src
,
WARMUP_RNG
).
out
(
dst
).
tbb_threads
(
cv
::
getNumberOfCPUs
());
TEST_CYCLE_N
(
1
)
{
weightedMedianFilter
(
joint
,
src
,
dst
,
r
,
sigma
,
weightType
);
}
SANITY_CHECK_NOTHING
();
}
}
modules/ximgproc/src/weighted_median_filter.cpp
0 → 100644
View file @
7b2c6f83
This diff is collapsed.
Click to expand it.
modules/ximgproc/test/test_weighted_median_filter.cpp
0 → 100644
View file @
7b2c6f83
/*
* By downloading, copying, installing or using the software you agree to this license.
* If you do not agree to this license, do not download, install,
* copy or use the software.
*
*
* License Agreement
* For Open Source Computer Vision Library
* (3 - clause BSD License)
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met :
*
* *Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and / or other materials provided with the distribution.
*
* * Neither the names of the copyright holders nor the names of the contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* This software is provided by the copyright holders and contributors "as is" and
* any express or implied warranties, including, but not limited to, the implied
* warranties of merchantability and fitness for a particular purpose are disclaimed.
* In no event shall copyright holders or contributors be liable for any direct,
* indirect, incidental, special, exemplary, or consequential damages
* (including, but not limited to, procurement of substitute goods or services;
* loss of use, data, or profits; or business interruption) however caused
* and on any theory of liability, whether in contract, strict liability,
* or tort(including negligence or otherwise) arising in any way out of
* the use of this software, even if advised of the possibility of such damage.
*/
#include "test_precomp.hpp"
namespace
cvtest
{
using
namespace
std
;
using
namespace
std
::
tr1
;
using
namespace
testing
;
using
namespace
perf
;
using
namespace
cv
;
using
namespace
cv
::
ximgproc
;
static
string
getDataDir
()
{
return
cvtest
::
TS
::
ptr
()
->
get_data_path
();
}
typedef
tuple
<
Size
,
WMFWeightType
>
WMFParams
;
typedef
TestWithParam
<
WMFParams
>
WeightedMedianFilterTest
;
TEST_P
(
WeightedMedianFilterTest
,
SplatSurfaceAccuracy
)
{
WMFParams
params
=
GetParam
();
Size
size
=
get
<
0
>
(
params
);
WMFWeightType
weightType
=
get
<
1
>
(
params
);
RNG
rnd
(
0
);
int
guideCn
=
rnd
.
uniform
(
1
,
2
);
if
(
guideCn
==
2
)
guideCn
++
;
//1 or 3 channels
Mat
guide
(
size
,
CV_MAKE_TYPE
(
CV_8U
,
guideCn
));
randu
(
guide
,
0
,
255
);
Scalar
surfaceValue
;
int
srcCn
=
rnd
.
uniform
(
1
,
4
);
rnd
.
fill
(
surfaceValue
,
RNG
::
UNIFORM
,
0
,
255
);
Mat
src
(
size
,
CV_MAKE_TYPE
(
CV_8U
,
srcCn
),
surfaceValue
);
int
r
=
int
(
rnd
.
uniform
(
3
,
11
));
double
sigma
=
rnd
.
uniform
(
9.0
,
100.0
);
Mat
res
;
weightedMedianFilter
(
guide
,
src
,
res
,
r
,
sigma
,
weightType
);
double
normL1
=
cvtest
::
norm
(
src
,
res
,
NORM_L1
)
/
src
.
total
()
/
src
.
channels
();
EXPECT_LE
(
normL1
,
1.0
/
64
);
}
TEST
(
WeightedMedianFilterTest
,
ReferenceAccuracy
)
{
string
dir
=
getDataDir
()
+
"cv/edgefilter"
;
Mat
src
=
imread
(
dir
+
"/kodim23.png"
);
Mat
ref
=
imread
(
dir
+
"/fgs/kodim23_lambda=1000_sigma=10.png"
);
ASSERT_FALSE
(
src
.
empty
());
ASSERT_FALSE
(
ref
.
empty
());
cv
::
setNumThreads
(
cv
::
getNumberOfCPUs
());
Mat
res
;
weightedMedianFilter
(
src
,
src
,
res
,
7
);
double
totalMaxError
=
1.0
/
32.0
*
src
.
total
()
*
src
.
channels
();
EXPECT_LE
(
cvtest
::
norm
(
res
,
ref
,
NORM_L2
),
totalMaxError
);
}
INSTANTIATE_TEST_CASE_P
(
TypicalSET
,
WeightedMedianFilterTest
,
Combine
(
Values
(
szODD
,
szQVGA
),
Values
(
WMF_EXP
,
WMF_IV2
,
WMF_OFF
)));
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment