Beispiel #1
0
        /// <summary>
        /// Applies weighted median filter to an image.
        /// </summary>
        /// <remarks>
        /// For more details about this implementation, please see @cite zhang2014100+
        /// </remarks>
        /// <param name="joint">Joint 8-bit, 1-channel or 3-channel image.</param>
        /// <param name="src">Source 8-bit or floating-point, 1-channel or 3-channel image.</param>
        /// <param name="dst">Destination image.</param>
        /// <param name="r">Radius of filtering kernel, should be a positive integer.</param>
        /// <param name="sigma">Filter range standard deviation for the joint image.</param>
        /// <param name="weightType">The type of weight definition, see WMFWeightType</param>
        /// <param name="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.</param>
        public static void WeightedMedianFilter(
            InputArray joint, InputArray src, OutputArray dst, int r,
            double sigma = 25.5, WMFWeightType weightType = WMFWeightType.EXP, Mat mask = null)
        {
            if (joint == null)
            {
                throw new ArgumentNullException(nameof(joint));
            }
            if (src == null)
            {
                throw new ArgumentNullException(nameof(src));
            }
            if (dst == null)
            {
                throw new ArgumentNullException(nameof(dst));
            }
            joint.ThrowIfDisposed();
            src.ThrowIfDisposed();
            dst.ThrowIfNotReady();

            NativeMethods.ximgproc_weightedMedianFilter(
                joint.CvPtr, src.CvPtr, dst.CvPtr, r, sigma, (int)weightType, mask?.CvPtr ?? IntPtr.Zero);

            GC.KeepAlive(joint);
            GC.KeepAlive(src);
            dst.Fix();
        }
Beispiel #2
0
 /// <summary>
 /// Applies weighted median filter to an image.
 /// </summary>
 /// <param name="joint">Joint 8-bit, 1-channel or 3-channel image.</param>
 /// <param name="src">Source 8-bit or floating-point, 1-channel or 3-channel image.</param>
 /// <param name="dst">Destination image.</param>
 /// <param name="r">Radius of filtering kernel, should be a positive integer.</param>
 /// <param name="sigma">Filter range standard deviation for the joint image.</param>
 /// <param name="weightType">The type of weight definition</param>
 /// <param name="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.</param>
 /// <remarks>For more details about this implementation, please see: Qi Zhang, Li Xu, and Jiaya Jia. 100+ times faster weighted median filter (wmf). In Computer Vision and Pattern Recognition (CVPR), 2014 IEEE Conference on, pages 2830–2837. IEEE, 2014.</remarks>
 public static void WeightedMedianFilter(IInputArray joint, IInputArray src, IOutputArray dst, int r,
                                         double sigma = 25.5, WMFWeightType weightType = WMFWeightType.Exp, Mat mask = null)
 {
     using (InputArray iaJoint = joint.GetInputArray())
         using (InputArray iaSrc = src.GetInputArray())
             using (OutputArray oaDst = dst.GetOutputArray())
             {
                 cveWeightedMedianFilter(iaJoint, iaSrc, oaDst, r, sigma, weightType, mask == null ? IntPtr.Zero : mask);
             }
 }
Beispiel #3
0
 private static extern void cveWeightedMedianFilter(IntPtr joint, IntPtr src, IntPtr dst, int r, double sigma, WMFWeightType weightType, IntPtr mask);