コード例 #1
0
 // ReSharper restore InconsistentNaming
 #endregion
 #region DistanceTransform
 /// <summary>
 /// builds the discrete Voronoi diagram
 /// </summary>
 /// <param name="src"></param>
 /// <param name="dst"></param>
 /// <param name="labels"></param>
 /// <param name="distanceType"></param>
 /// <param name="maskSize"></param>
 /// <param name="labelType"></param>
 public static void DistanceTransformWithLabels(InputArray src,
                                                OutputArray dst,
                                                OutputArray labels,
                                                DistanceType distanceType,
                                                DistanceMaskSize maskSize,
                                                DistTransformLabelType labelType = DistTransformLabelType.CComp)
 {
     if (src == null)
         throw new ArgumentNullException("src");
     if (dst == null)
         throw new ArgumentNullException("dst");
     if (labels == null)
         throw new ArgumentNullException("labels");
     src.ThrowIfDisposed();
     dst.ThrowIfNotReady();
     labels.ThrowIfNotReady();
     NativeMethods.imgproc_distanceTransformWithLabels(
         src.CvPtr, dst.CvPtr, labels.CvPtr, (int)distanceType, (int)maskSize, (int)labelType);
     dst.Fix();
     labels.Fix();
 }
コード例 #2
0
ファイル: Cv_D.cs プロジェクト: 0sv/opencvsharp
        /// <summary>
        /// 入力画像中の値が0でないピクセルから,最も近い値が0のピクセルまでの距離を計算する
        /// </summary>
        /// <param name="src">入力画像(8ビット,シングルチャンネル,2値画像)</param>
        /// <param name="dst">距離計算結果をピクセル値として持つ出力画像 (32ビット浮動小数点型,シングルチャンネル)</param>
        /// <param name="distanceType">距離の種類.L1, L2, C か User</param>
        /// <param name="maskSize">距離変換マスクのサイズで,3,5,0 のいずれか. L1,C の場合,このパラメータ値は3に固定される.mask_size==0の場合,距離計算に別の近似無しアルゴリズムが用いられる.</param>
        /// <param name="mask">ユーザ定義の距離の場合はユーザ定義のマスク.3×3のマスクを用いる場合は2つの値(上下シフト値,斜めシフト値)を指定,5×5のマスクを用いる場合は3つの値(上下シフト値,斜めシフト値,ナイト移動シフト値(桂馬飛びのシフト値))を指定する.</param>
        /// <param name="labels">オプション出力.整数ラベルに変換された2次元配列で,src ,dstと同じサイズ.現在は mask_size==3 あるいは 5 のときのみに使用される.</param>
        /// <param name="labelType"></param>
#else
        /// <summary>
        /// Calculates distance to closest zero pixel for all non-zero pixels of source image.
        /// </summary>
        /// <param name="src">Source 8-bit single-channel (binary) image. </param>
        /// <param name="dst">Output image with calculated distances (32-bit floating-point, single-channel). </param>
        /// <param name="distanceType">Type of distance. </param>
        /// <param name="maskSize">Size of distance transform mask; can be 3, 5 or 0. In case of CV_DIST_L1 or CV_DIST_C the parameter is forced to 3, because 3×3 mask gives the same result as 5x5 yet it is faster. When mask_size==0, a different non-approximate algorithm is used to calculate distances. </param>
        /// <param name="mask">User-defined mask in case of user-defined distance, it consists of 2 numbers (horizontal/vertical shift cost, diagonal shift cost) in case of 3x3 mask and 3 numbers (horizontal/vertical shift cost, diagonal shift cost, knight’s move cost) in case of 5x5 mask. </param>
        /// <param name="labels">The optional output 2d array of labels of integer type and the same size as src and dst, can now be used only with mask_size==3 or 5. </param>
        /// <param name="labelType"></param>
#endif
        public static void DistTransform(CvArr src, CvArr dst, DistanceType distanceType, int maskSize, float[] mask, CvArr labels, DistTransformLabelType labelType)
        {
            if (src == null)
                throw new ArgumentNullException("src");
            if (dst == null)
                throw new ArgumentNullException("dst");
            IntPtr labelsPtr = (labels == null) ? IntPtr.Zero : labels.CvPtr;
            NativeMethods.cvDistTransform(src.CvPtr, dst.CvPtr, distanceType, maskSize, mask, labelsPtr, labelType);
        }
コード例 #3
0
ファイル: Cv_D.cs プロジェクト: shimat/opencvsharp_2410
        /// <summary>
        /// 入力画像中の値が0でないピクセルから,最も近い値が0のピクセルまでの距離を計算する
        /// </summary>
        /// <param name="src">入力画像(8ビット,シングルチャンネル,2値画像)</param>
        /// <param name="dst">距離計算結果をピクセル値として持つ出力画像 (32ビット浮動小数点型,シングルチャンネル)</param>
        /// <param name="distanceType">距離の種類.L1, L2, C か User</param>
        /// <param name="maskSize">距離変換マスクのサイズで,3,5,0 のいずれか. L1,C の場合,このパラメータ値は3に固定される.mask_size==0の場合,距離計算に別の近似無しアルゴリズムが用いられる.</param>
        /// <param name="mask">ユーザ定義の距離の場合はユーザ定義のマスク.3×3のマスクを用いる場合は2つの値(上下シフト値,斜めシフト値)を指定,5×5のマスクを用いる場合は3つの値(上下シフト値,斜めシフト値,ナイト移動シフト値(桂馬飛びのシフト値))を指定する.</param>
        /// <param name="labels">オプション出力.整数ラベルに変換された2次元配列で,src ,dstと同じサイズ.現在は mask_size==3 あるいは 5 のときのみに使用される.</param>
        /// <param name="labelType"></param>
#else
        /// <summary>
        /// Calculates distance to closest zero pixel for all non-zero pixels of source image.
        /// </summary>
        /// <param name="src">Source 8-bit single-channel (binary) image. </param>
        /// <param name="dst">Output image with calculated distances (32-bit floating-point, single-channel). </param>
        /// <param name="distanceType">Type of distance. </param>
        /// <param name="maskSize">Size of distance transform mask; can be 3, 5 or 0. In case of CV_DIST_L1 or CV_DIST_C the parameter is forced to 3, because 3×3 mask gives the same result as 5x5 yet it is faster. When mask_size==0, a different non-approximate algorithm is used to calculate distances. </param>
        /// <param name="mask">User-defined mask in case of user-defined distance, it consists of 2 numbers (horizontal/vertical shift cost, diagonal shift cost) in case of 3x3 mask and 3 numbers (horizontal/vertical shift cost, diagonal shift cost, knight’s move cost) in case of 5x5 mask. </param>
        /// <param name="labels">The optional output 2d array of labels of integer type and the same size as src and dst, can now be used only with mask_size==3 or 5. </param>
        /// <param name="labelType"></param>
#endif
        public static void DistTransform(CvArr src, CvArr dst, DistanceType distanceType, int maskSize, float[] mask, CvArr labels, DistTransformLabelType labelType)
        {
            if (src == null)
            {
                throw new ArgumentNullException(nameof(src));
            }
            if (dst == null)
            {
                throw new ArgumentNullException(nameof(dst));
            }
            NativeMethods.cvDistTransform(src.CvPtr, dst.CvPtr, distanceType, maskSize, mask, ToPtr(labels), labelType);
            KeepAlive(src, dst, mask, labels);
        }
コード例 #4
0
        /// <summary>
        /// 入力画像中の値が0でないピクセルから,最も近い値が0のピクセルまでの距離を計算する
        /// </summary>
        /// <param name="src">入力画像(8ビット,シングルチャンネル,2値画像)</param>
        /// <param name="dst">距離計算結果をピクセル値として持つ出力画像 (32ビット浮動小数点型,シングルチャンネル)</param>
        /// <param name="distanceType">距離の種類.L1, L2, C か User</param>
        /// <param name="maskSize">距離変換マスクのサイズで,3,5,0 のいずれか. L1,C の場合,このパラメータ値は3に固定される.mask_size==0の場合,距離計算に別の近似無しアルゴリズムが用いられる.</param>
        /// <param name="mask">ユーザ定義の距離の場合はユーザ定義のマスク.3×3のマスクを用いる場合は2つの値(上下シフト値,斜めシフト値)を指定,5×5のマスクを用いる場合は3つの値(上下シフト値,斜めシフト値,ナイト移動シフト値(桂馬飛びのシフト値))を指定する.</param>
        /// <param name="labels">オプション出力.整数ラベルに変換された2次元配列で,src ,dstと同じサイズ.現在は mask_size==3 あるいは 5 のときのみに使用される.</param>
        /// <param name="labelType"></param>
#else
        /// <summary>
        /// Calculates distance to closest zero pixel for all non-zero pixels of source image.
        /// </summary>
        /// <param name="src">Source 8-bit single-channel (binary) image. </param>
        /// <param name="dst">Output image with calculated distances (32-bit floating-point, single-channel). </param>
        /// <param name="distanceType">Type of distance. </param>
        /// <param name="maskSize">Size of distance transform mask; can be 3, 5 or 0. In case of CV_DIST_L1 or CV_DIST_C the parameter is forced to 3, because 3×3 mask gives the same result as 5x5 yet it is faster. When mask_size==0, a different non-approximate algorithm is used to calculate distances. </param>
        /// <param name="mask">User-defined mask in case of user-defined distance, it consists of 2 numbers (horizontal/vertical shift cost, diagonal shift cost) in case of 3x3 mask and 3 numbers (horizontal/vertical shift cost, diagonal shift cost, knight’s move cost) in case of 5x5 mask. </param>
        /// <param name="labels">The optional output 2d array of labels of integer type and the same size as src and dst, can now be used only with mask_size==3 or 5. </param>
        /// <param name="labelType"></param>
#endif
        public static void DistTransform(CvArr src, CvArr dst, DistanceType distanceType, int maskSize, float[] mask, CvArr labels, DistTransformLabelType labelType)
        {
            if (src == null)
                throw new ArgumentNullException("src");
            if (dst == null)
                throw new ArgumentNullException("dst");
            IntPtr labelsPtr = (labels == null) ? IntPtr.Zero : labels.CvPtr;
            NativeMethods.cvDistTransform(src.CvPtr, dst.CvPtr, distanceType, maskSize, mask, labelsPtr, labelType);
        }