1 /*M/////////////////////////////////////////////////////////////////////////////////////// 2 // 3 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. 4 // 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. 8 // 9 // 10 // License Agreement 11 // For Open Source Computer Vision Library 12 // 13 // Copyright (C) 2015, The Chinese University of Hong Kong, all rights reserved. 14 // 15 // Third party copyrights are property of their respective owners. 16 // 17 // Redistribution and use in source and binary forms, with or without modification, 18 // are permitted provided that the following conditions are met: 19 // 20 // * Redistribution's of source code must retain the above copyright notice, 21 // this list of conditions and the following disclaimer. 22 // 23 // * Redistribution's in binary form must reproduce the above copyright notice, 24 // this list of conditions and the following disclaimer in the documentation 25 // and/or other materials provided with the distribution. 26 // 27 // * The name of the copyright holders may not be used to endorse or promote products 28 // derived from this software without specific prior written permission. 29 // 30 // This software is provided by the copyright holders and contributors "as is" and 31 // any express or implied warranties, including, but not limited to, the implied 32 // warranties of merchantability and fitness for a particular purpose are disclaimed. 33 // In no event shall the Intel Corporation or contributors be liable for any direct, 34 // indirect, incidental, special, exemplary, or consequential damages 35 // (including, but not limited to, procurement of substitute goods or services; 36 // loss of use, data, or profits; or business interruption) however caused 37 // and on any theory of liability, whether in contract, strict liability, 38 // or tort (including negligence or otherwise) arising in any way out of 39 // the use of this software, even if advised of the possibility of such damage. 40 // 41 //M*/ 42 43 #ifndef __OPENCV_WEIGHTED_MEDIAN_FILTER_HPP__ 44 #define __OPENCV_WEIGHTED_MEDIAN_FILTER_HPP__ 45 #ifdef __cplusplus 46 47 /** 48 * @file 49 * @date Sept 9, 2015 50 * @author Zhou Chao 51 */ 52 53 #include <opencv2/core.hpp> 54 #include <string> 55 56 namespace cv 57 { 58 namespace ximgproc 59 { 60 61 /** 62 * @brief Specifies weight types of weighted median filter. 63 */ 64 enum WMFWeightType 65 { 66 WMF_EXP = 1 , //!< \f$exp(-|I1-I2|^2/(2*sigma^2))\f$ 67 WMF_IV1 = 1 << 1, //!< \f$(|I1-I2|+sigma)^-1\f$ 68 WMF_IV2 = 1 << 2, //!< \f$(|I1-I2|^2+sigma^2)^-1\f$ 69 WMF_COS = 1 << 3, //!< \f$dot(I1,I2)/(|I1|*|I2|)\f$ 70 WMF_JAC = 1 << 4, //!< \f$(min(r1,r2)+min(g1,g2)+min(b1,b2))/(max(r1,r2)+max(g1,g2)+max(b1,b2))\f$ 71 WMF_OFF = 1 << 5 //!< unweighted 72 }; 73 74 /** 75 * @brief Applies weighted median filter to an image. 76 * 77 * For more details about this implementation, please see @cite zhang2014100+ 78 * 79 * @param joint Joint 8-bit, 1-channel or 3-channel image. 80 * @param src Source 8-bit or floating-point, 1-channel or 3-channel image. 81 * @param dst Destination image. 82 * @param r Radius of filtering kernel, should be a positive integer. 83 * @param sigma Filter range standard deviation for the joint image. 84 * @param weightType weightType The type of weight definition, see WMFWeightType 85 * @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, 86 * the pixel will be ignored when maintaining the joint-histogram. This is useful for applications like optical flow occlusion handling. 87 * 88 * @sa medianBlur, jointBilateralFilter 89 */ 90 CV_EXPORTS_W void weightedMedianFilter(InputArray joint, InputArray src, OutputArray dst, 91 int r, double sigma = 25.5, int weightType = WMF_EXP, InputArray mask = noArray()); 92 } 93 } 94 95 #endif 96 #endif 97