Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions modules/ximgproc/doc/ximgproc.bib
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,21 @@ @InProceedings{LiCVPR2015LSC
month = {June},
year = {2015}
}

@incollection{zhang2014rolling,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reference to this paper should be added to the corresponding filter documentation.

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}
}
1 change: 1 addition & 0 deletions modules/ximgproc/include/opencv2/ximgproc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 2 additions & 0 deletions modules/ximgproc/include/opencv2/ximgproc/edge_filter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/*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
88 changes: 88 additions & 0 deletions modules/ximgproc/perf/perf_weighted_median_filter.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
* 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();
}
}
Loading