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


C# MatType类代码示例

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


MatType类属于命名空间,在下文中一共展示了MatType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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

示例3: ConnectedComponentsWithStats

        /// <summary>
        /// computes the connected components labeled image of boolean image. 
        /// image with 4 or 8 way connectivity - returns N, the total number of labels [0, N-1] where 0 
        /// represents the background label. ltype specifies the output label image type, an important 
        /// consideration based on the total number of labels or alternatively the total number of 
        /// pixels in the source image.
        /// </summary>
        /// <param name="image">the image to be labeled</param>
        /// <param name="labels">destination labeled image</param>
        /// <param name="stats">statistics output for each label, including the background label, 
        /// see below for available statistics. Statistics are accessed via stats(label, COLUMN) 
        /// where COLUMN is one of cv::ConnectedComponentsTypes</param>
        /// <param name="centroids">floating point centroid (x,y) output for each label, 
        /// including the background label</param>
        /// <param name="connectivity">8 or 4 for 8-way or 4-way connectivity respectively</param>
        /// <param name="ltype">output image label type. Currently CV_32S and CV_16U are supported.</param>
        /// <returns></returns>
        public static int ConnectedComponentsWithStats(
            InputArray image, OutputArray labels,
            OutputArray stats, OutputArray centroids,
            PixelConnectivity connectivity,
            MatType ltype)
        {
            if (image == null)
                throw new ArgumentNullException(nameof(image));
            if (labels == null)
                throw new ArgumentNullException(nameof(labels));
            if (stats == null)
                throw new ArgumentNullException(nameof(stats));
            if (centroids == null)
                throw new ArgumentNullException(nameof(centroids));
            image.ThrowIfDisposed();
            labels.ThrowIfNotReady();
            stats.ThrowIfNotReady();
            centroids.ThrowIfNotReady();

            int result = NativeMethods.imgproc_connectedComponentsWithStats(
                image.CvPtr, labels.CvPtr, stats.CvPtr, centroids.CvPtr, (int) connectivity, ltype);

            GC.KeepAlive(image);
            labels.Fix();
            stats.Fix();
            centroids.Fix();
            return result;
        }
开发者ID:shimat,项目名称:opencvsharp,代码行数:45,代码来源:Cv2_imgproc.cs

示例4: CalcCovarMatrix

 /// <summary>
 /// computes covariation matrix of a set of samples
 /// </summary>
 /// <param name="samples"></param>
 /// <param name="covar"></param>
 /// <param name="mean"></param>
 /// <param name="flags"></param>
 /// <param name="ctype"></param>
 public static void CalcCovarMatrix(InputArray samples, OutputArray covar,
     InputOutputArray mean, CovarFlags flags, MatType ctype)
 {
     if (samples == null)
         throw new ArgumentNullException("samples");
     if (covar == null)
         throw new ArgumentNullException("covar");
     if (mean == null)
         throw new ArgumentNullException("mean");
     samples.ThrowIfDisposed();
     covar.ThrowIfNotReady();
     mean.ThrowIfNotReady();
     NativeMethods.core_calcCovarMatrix_InputArray(samples.CvPtr, covar.CvPtr, mean.CvPtr, (int)flags, ctype);
     GC.KeepAlive(samples); 
     covar.Fix();
     mean.Fix();
 }
开发者ID:fdncred,项目名称:opencvsharp,代码行数:25,代码来源:Cv2_core.cs

示例5: CreateHanningWindow

 /// <summary>
 /// Computes a Hanning window coefficients in two dimensions.
 /// </summary>
 /// <param name="winSize">The window size specifications</param>
 /// <param name="type">Created array type</param>
 public void CreateHanningWindow(Size winSize, MatType type)
 {
     Cv2.CreateHanningWindow(this, winSize, type);
 }
开发者ID:MJunak,项目名称:opencvsharp,代码行数:9,代码来源:Mat_CvMethods.cs

示例6: Scharr

 /// <summary>
 /// Calculates the first x- or y- image derivative using Scharr operator
 /// </summary>
 /// <param name="ddepth">The destination image depth</param>
 /// <param name="xorder">Order of the derivative x</param>
 /// <param name="yorder">Order of the derivative y</param>
 /// <param name="scale">The optional scale factor for the computed derivative values (by default, no scaling is applie</param>
 /// <param name="delta">The optional delta value, added to the results prior to storing them in dst</param>
 /// <param name="borderType">The pixel extrapolation method</param>
 /// <returns>The destination image; will have the same size and the same number of channels as src</returns>
 public Mat Scharr(MatType ddepth, int xorder, int yorder,
     double scale = 1, double delta = 0, BorderType borderType = BorderType.Default)
 {
     var dst = new Mat();
     Cv2.Scharr(this, dst, ddepth, xorder, yorder, scale, delta, borderType);
     return dst;
 }
开发者ID:MJunak,项目名称:opencvsharp,代码行数:17,代码来源:Mat_CvMethods.cs

示例7: BoxFilter

 /// <summary>
 /// Smoothes image using box filter
 /// </summary>
 /// <param name="ddepth"></param>
 /// <param name="ksize">The smoothing kernel size</param>
 /// <param name="anchor">The anchor point. The default value Point(-1,-1) means that the anchor is at the kernel center</param>
 /// <param name="normalize">Indicates, whether the kernel is normalized by its area or not</param>
 /// <param name="borderType">The border mode used to extrapolate pixels outside of the image</param>
 /// <returns>The destination image; will have the same size and the same type as src</returns>
 public Mat BoxFilter(MatType ddepth, Size ksize, Point? anchor = null, 
     bool normalize = true, BorderType borderType = BorderType.Default)
 {
     var dst = new Mat();
     Cv2.BoxFilter(this, dst, ddepth, ksize, anchor, normalize, borderType);
     return dst;
 }
开发者ID:MJunak,项目名称:opencvsharp,代码行数:16,代码来源:Mat_CvMethods.cs

示例8: Laplacian

 /// <summary>
 /// Calculates the Laplacian of an image
 /// </summary>
 /// <param name="src">Source image</param>
 /// <param name="dst">Destination image; will have the same size and the same number of channels as src</param>
 /// <param name="ddepth">The desired depth of the destination image</param>
 /// <param name="ksize">The aperture size used to compute the second-derivative filters</param>
 /// <param name="scale">The optional scale factor for the computed Laplacian values (by default, no scaling is applied</param>
 /// <param name="delta">The optional delta value, added to the results prior to storing them in dst</param>
 /// <param name="borderType">The pixel extrapolation method</param>
 public static void Laplacian(InputArray src, OutputArray dst, MatType ddepth,
     int ksize = 1, double scale = 1, double delta = 0, BorderType borderType = BorderType.Default)
 {
     if (src == null)
         throw new ArgumentNullException("src");
     if (dst == null)
         throw new ArgumentNullException("dst");
     src.ThrowIfDisposed();
     dst.ThrowIfNotReady();
     NativeMethods.imgproc_Laplacian(src.CvPtr, dst.CvPtr, ddepth, ksize, scale, delta, (int)borderType);
     dst.Fix();
 }
开发者ID:josephgodwinkimani,项目名称:opencvsharp,代码行数:22,代码来源:Cv2_imgproc.cs

示例9: BoxFilter

 /// <summary>
 /// Smoothes image using box filter
 /// </summary>
 /// <param name="src">The source image</param>
 /// <param name="dst">The destination image; will have the same size and the same type as src</param>
 /// <param name="ddepth"></param>
 /// <param name="ksize">The smoothing kernel size</param>
 /// <param name="anchor">The anchor point. The default value Point(-1,-1) means that the anchor is at the kernel center</param>
 /// <param name="normalize">Indicates, whether the kernel is normalized by its area or not</param>
 /// <param name="borderType">The border mode used to extrapolate pixels outside of the image</param>
 public static void BoxFilter(InputArray src, OutputArray dst, MatType ddepth, 
     Size ksize, Point? anchor = null, bool normalize = true, BorderType borderType = BorderType.Default)
 {
     if (src == null)
         throw new ArgumentNullException("src");
     if (dst == null)
         throw new ArgumentNullException("dst");
     src.ThrowIfDisposed();
     dst.ThrowIfNotReady();
     Point anchor0 = anchor.GetValueOrDefault(new Point(-1, -1));
     NativeMethods.imgproc_boxFilter(src.CvPtr, dst.CvPtr, ddepth, ksize, anchor0, normalize ? 1 : 0, (int)borderType);
     dst.Fix();
 }
开发者ID:josephgodwinkimani,项目名称:opencvsharp,代码行数:23,代码来源:Cv2_imgproc.cs

示例10: CreateContinuous

 /// <summary>
 /// Creates continuous GPU matrix
 /// </summary>
 /// <param name="size">Number of rows and columns in a 2D array.</param>
 /// <param name="type">Array type.</param>
 /// <returns></returns>
 public static GpuMat CreateContinuous(Size size, MatType type)
 {
     ThrowIfGpuNotAvailable();
     return CreateContinuous(size.Height, size.Width, type);
 }
开发者ID:shimat,项目名称:opencvsharp,代码行数:11,代码来源:Cv2_cuda.cs

示例11: Scharr

 /// <summary>
 /// Calculates the first x- or y- image derivative using Scharr operator
 /// </summary>
 /// <param name="src">The source image</param>
 /// <param name="dst">The destination image; will have the same size and the same number of channels as src</param>
 /// <param name="ddepth">The destination image depth</param>
 /// <param name="xorder">Order of the derivative x</param>
 /// <param name="yorder">Order of the derivative y</param>
 /// <param name="scale">The optional scale factor for the computed derivative values (by default, no scaling is applie</param>
 /// <param name="delta">The optional delta value, added to the results prior to storing them in dst</param>
 /// <param name="borderType">The pixel extrapolation method</param>
 public static void Scharr(
     InputArray src, OutputArray dst, MatType ddepth, int xorder, int yorder, 
     double scale = 1, double delta = 0, BorderTypes borderType = BorderTypes.Default)
 {
     if (src == null)
         throw new ArgumentNullException(nameof(src));
     if (dst == null)
         throw new ArgumentNullException(nameof(dst));
     src.ThrowIfDisposed();
     dst.ThrowIfNotReady();
     NativeMethods.imgproc_Scharr(src.CvPtr, dst.CvPtr, ddepth, xorder, yorder, 
         scale, delta, (int)borderType);
     GC.KeepAlive(src);
     dst.Fix();
 }
开发者ID:shimat,项目名称:opencvsharp,代码行数:26,代码来源:Cv2_imgproc.cs

示例12: Filter2D

        /// <summary>
        /// Convolves an image with the kernel
        /// </summary>
        /// <param name="src">The source image</param>
        /// <param name="dst">The destination image. It will have the same size and the same number of channels as src</param>
        /// <param name="ddepth">The desired depth of the destination image. If it is negative, it will be the same as src.depth()</param>
        /// <param name="kernel">Convolution kernel (or rather a correlation kernel), 
        /// a single-channel floating point matrix. If you want to apply different kernels to 
        /// different channels, split the image into separate color planes using split() and process them individually</param>
        /// <param name="anchor">The anchor of the kernel that indicates the relative position of 
        /// a filtered point within the kernel. The anchor should lie within the kernel. 
        /// The special default value (-1,-1) means that the anchor is at the kernel center</param>
        /// <param name="delta">The optional value added to the filtered pixels before storing them in dst</param>
        /// <param name="borderType">The pixel extrapolation method</param>
        public static void Filter2D(
            InputArray src, OutputArray dst, MatType ddepth,
	        InputArray kernel, Point? anchor = null, double delta = 0, 
            BorderTypes borderType = BorderTypes.Default)
        {
            if (src == null)
                throw new ArgumentNullException(nameof(src));
            if (dst == null)
                throw new ArgumentNullException(nameof(dst));
            if (kernel == null)
                throw new ArgumentNullException(nameof(kernel));
            src.ThrowIfDisposed();
            dst.ThrowIfNotReady();
            kernel.ThrowIfDisposed();
            Point anchor0 = anchor.GetValueOrDefault(new Point(-1, -1));
            NativeMethods.imgproc_filter2D(src.CvPtr, dst.CvPtr, ddepth, kernel.CvPtr, 
                anchor0, delta, (int)borderType);
            GC.KeepAlive(src);
            dst.Fix();
        }
开发者ID:shimat,项目名称:opencvsharp,代码行数:34,代码来源:Cv2_imgproc.cs

示例13: InitUndistortRectifyMap

 /// <summary>
 /// initializes maps for cv::remap() to correct lens distortion and optionally rectify the image
 /// </summary>
 /// <param name="cameraMatrix"></param>
 /// <param name="distCoeffs"></param>
 /// <param name="r"></param>
 /// <param name="newCameraMatrix"></param>
 /// <param name="size"></param>
 /// <param name="m1Type"></param>
 /// <param name="map1"></param>
 /// <param name="map2"></param>
 public static void InitUndistortRectifyMap(InputArray cameraMatrix, InputArray distCoeffs,
     InputArray r, InputArray newCameraMatrix,
     Size size, MatType m1Type, OutputArray map1, OutputArray map2)
 {
     if (cameraMatrix == null)
         throw new ArgumentNullException("cameraMatrix");
     if (distCoeffs == null)
         throw new ArgumentNullException("distCoeffs");
     if (r == null)
         throw new ArgumentNullException("r");
     if (newCameraMatrix == null)
         throw new ArgumentNullException("newCameraMatrix");
     if (map1 == null)
         throw new ArgumentNullException("map1");
     if (map2 == null)
         throw new ArgumentNullException("map2");
     cameraMatrix.ThrowIfDisposed();
     distCoeffs.ThrowIfDisposed();
     r.ThrowIfDisposed();
     newCameraMatrix.ThrowIfDisposed();
     map1.ThrowIfNotReady();
     map2.ThrowIfNotReady();
     NativeMethods.imgproc_initUndistortRectifyMap(
         cameraMatrix.CvPtr, distCoeffs.CvPtr, r.CvPtr, newCameraMatrix.CvPtr, size, m1Type, map1.CvPtr, map2.CvPtr);
     map1.Fix();
     map2.Fix();
 }
开发者ID:josephgodwinkimani,项目名称:opencvsharp,代码行数:38,代码来源:Cv2_imgproc.cs

示例14: InitWideAngleProjMap

 /// <summary>
 /// initializes maps for cv::remap() for wide-angle
 /// </summary>
 /// <param name="cameraMatrix"></param>
 /// <param name="distCoeffs"></param>
 /// <param name="imageSize"></param>
 /// <param name="destImageWidth"></param>
 /// <param name="m1Type"></param>
 /// <param name="map1"></param>
 /// <param name="map2"></param>
 /// <param name="projType"></param>
 /// <param name="alpha"></param>
 /// <returns></returns>
 public static float InitWideAngleProjMap(InputArray cameraMatrix, InputArray distCoeffs,
     Size imageSize, int destImageWidth, MatType m1Type, OutputArray map1, OutputArray map2,
     ProjectionType projType, double alpha = 0)
 {
     if (cameraMatrix == null)
         throw new ArgumentNullException("cameraMatrix");
     if (distCoeffs == null)
         throw new ArgumentNullException("distCoeffs");
     if (map1 == null)
         throw new ArgumentNullException("map1");
     if (map2 == null)
         throw new ArgumentNullException("map2");
     cameraMatrix.ThrowIfDisposed();
     distCoeffs.ThrowIfDisposed();
     map1.ThrowIfNotReady();
     map2.ThrowIfNotReady();
     float ret = NativeMethods.imgproc_initWideAngleProjMap(cameraMatrix.CvPtr, distCoeffs.CvPtr, imageSize,
         destImageWidth, m1Type, map1.CvPtr, map2.CvPtr, (int)projType, alpha);
     map1.Fix();
     map2.Fix();
     return ret;
 }
开发者ID:josephgodwinkimani,项目名称:opencvsharp,代码行数:35,代码来源:Cv2_imgproc.cs

示例15: EnsureSizeIsEnough

 /// <summary>
 /// Ensures that size of the given matrix is not less than (rows, cols) size
 /// and matrix type is match specified one too
 /// </summary>
 /// <param name="rows">Number of rows in a 2D array.</param>
 /// <param name="cols">Number of columns in a 2D array.</param>
 /// <param name="type">Array type.</param>
 /// <param name="m"></param>
 public static void EnsureSizeIsEnough(int rows, int cols, MatType type, GpuMat m)
 {
     ThrowIfGpuNotAvailable();
     if (m == null)
         throw new ArgumentNullException(nameof(m));
     NativeMethods.cuda_ensureSizeIsEnough(rows, cols, type, m.CvPtr);
 }
开发者ID:shimat,项目名称:opencvsharp,代码行数:15,代码来源:Cv2_cuda.cs


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