当前位置: 首页>>代码示例>>C#>>正文


C# MatType.GetValueOrDefault方法代码示例

本文整理汇总了C#中MatType.GetValueOrDefault方法的典型用法代码示例。如果您正苦于以下问题:C# MatType.GetValueOrDefault方法的具体用法?C# MatType.GetValueOrDefault怎么用?C# MatType.GetValueOrDefault使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MatType的用法示例。


在下文中一共展示了MatType.GetValueOrDefault方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetGaussianKernel

 /// <summary>
 /// Returns Gaussian filter coefficients.
 /// </summary>
 /// <param name="ksize">Aperture size. It should be odd and positive.</param>
 /// <param name="sigma">Gaussian standard deviation.
 /// If it is non-positive, it is computed from ksize as `sigma = 0.3*((ksize-1)*0.5 - 1) + 0.8`.</param>
 /// <param name="ktype">Type of filter coefficients. It can be CV_32F or CV_64F.</param>
 /// <returns></returns>
 public static Mat GetGaussianKernel(int ksize, double sigma, MatType? ktype = null)
 {
     var ktype0 = ktype.GetValueOrDefault(MatType.CV_64F);
     var ret = NativeMethods.imgproc_getGaussianKernel(ksize, sigma, ktype0);
     if (ret == IntPtr.Zero)
         return null;
     return new Mat(ret);
 }
开发者ID:shimat,项目名称:opencvsharp,代码行数:16,代码来源:Cv2_imgproc.cs

示例2: GetDerivKernels

        /// <summary>
        /// Returns filter coefficients for computing spatial image derivatives.
        /// </summary>
        /// <param name="kx">Output matrix of row filter coefficients. It has the type ktype.</param>
        /// <param name="ky">Output matrix of column filter coefficients. It has the type ktype.</param>
        /// <param name="dx">Derivative order in respect of x.</param>
        /// <param name="dy">Derivative order in respect of y.</param>
        /// <param name="ksize">Aperture size. It can be CV_SCHARR, 1, 3, 5, or 7.</param>
        /// <param name="normalize">Flag indicating whether to normalize (scale down) the filter coefficients or not.
        /// Theoretically, the coefficients should have the denominator \f$=2^{ksize*2-dx-dy-2}\f$. 
        /// If you are going to filter floating-point images, you are likely to use the normalized kernels.
        /// But if you compute derivatives of an 8-bit image, store the results in a 16-bit image, 
        /// and wish to preserve all the fractional bits, you may want to set normalize = false.</param>
        /// <param name="ktype">Type of filter coefficients. It can be CV_32f or CV_64F.</param>
        public static void GetDerivKernels(
            OutputArray kx, OutputArray ky, int dx, int dy, int ksize,
            bool normalize = false, MatType? ktype = null)
        {
            if (kx == null)
                throw new ArgumentNullException(nameof(kx));
            if (ky == null)
                throw new ArgumentNullException(nameof(ky));
            kx.ThrowIfNotReady();
            ky.ThrowIfNotReady();

            var ktype0 = ktype.GetValueOrDefault(MatType.CV_32F);
            NativeMethods.imgproc_getDerivKernels(
                kx.CvPtr, ky.CvPtr, dx, dy, ksize, normalize ? 1 : 0, ktype0);

            kx.Fix();
            ky.Fix();
        }
开发者ID:shimat,项目名称:opencvsharp,代码行数:32,代码来源:Cv2_imgproc.cs


注:本文中的MatType.GetValueOrDefault方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。