/// <summary> /// 高度なモルフォロジー変換を行います. /// </summary> /// <param name="src">入力画像</param> /// <param name="dst">src と同じサイズ,同じ型の出力画像</param> /// <param name="op">モルフォロジー演算の種類</param> /// <param name="element">構造要素</param> /// <param name="anchor">構造要素内のアンカー位置.デフォルト値の (-1, -1) は,アンカーが構造要素の中心にあることを意味します.</param> /// <param name="iterations">収縮と膨張が適用される回数. [既定値は1]</param> /// <param name="borderType">ピクセル外挿手法. [既定値はBorderType.Constant]</param> /// <param name="borderValue">定数境界モードで利用されるピクセル値.デフォルト値は特別な意味を持ちます. [既定値は CvCpp.MorphologyDefaultBorderValue()]</param> #else /// <summary> /// Performs advanced morphological transformations /// </summary> /// <param name="src">Source image</param> /// <param name="dst">Destination image. It will have the same size and the same type as src</param> /// <param name="op">Type of morphological operation</param> /// <param name="element">Structuring element</param> /// <param name="anchor">Position of the anchor within the element. The default value (-1, -1) means that the anchor is at the element center</param> /// <param name="iterations">Number of times erosion and dilation are applied. [By default this is 1]</param> /// <param name="borderType">The pixel extrapolation method. [By default this is BorderType.Constant]</param> /// <param name="borderValue">The border value in case of a constant border. The default value has a special meaning. [By default this is CvCpp.MorphologyDefaultBorderValue()]</param> #endif public static void MorphologyEx(InputArray src, OutputArray dst, MorphologyOperation op, InputArray element, CvPoint? anchor = null, int iterations = 1, BorderType borderType = BorderType.Constant, CvScalar? borderValue = null) { if (src == null) throw new ArgumentNullException("src"); if (dst == null) throw new ArgumentNullException("dst"); src.ThrowIfDisposed(); dst.ThrowIfNotReady(); CvPoint anchor0 = anchor.GetValueOrDefault(new CvPoint(-1, -1)); CvScalar borderValue0 = borderValue.GetValueOrDefault(MorphologyDefaultBorderValue()); IntPtr elementPtr = ToPtr(element); NativeMethods.imgproc_morphologyEx(src.CvPtr, dst.CvPtr, (int)op, elementPtr, anchor0, iterations, (int)borderType, borderValue0); dst.Fix(); }
/// <summary> /// 高度なモルフォロジー変換を行います. /// </summary> /// <param name="src">入力画像</param> /// <param name="dst">src と同じサイズ,同じ型の出力画像</param> /// <param name="op">モルフォロジー演算の種類</param> /// <param name="element">構造要素</param> /// <param name="anchor">構造要素内のアンカー位置.デフォルト値の (-1, -1) は,アンカーが構造要素の中心にあることを意味します.</param> /// <param name="iterations">収縮と膨張が適用される回数. [既定値は1]</param> /// <param name="borderType">ピクセル外挿手法. [既定値はBorderType.Constant]</param> /// <param name="borderValue">定数境界モードで利用されるピクセル値.デフォルト値は特別な意味を持ちます. [既定値は CvCpp.MorphologyDefaultBorderValue()]</param> #else /// <summary> /// Performs advanced morphological transformations /// </summary> /// <param name="src">Source image</param> /// <param name="dst">Destination image. It will have the same size and the same type as src</param> /// <param name="op">Type of morphological operation</param> /// <param name="element">Structuring element</param> /// <param name="anchor">Position of the anchor within the element. The default value (-1, -1) means that the anchor is at the element center</param> /// <param name="iterations">Number of times erosion and dilation are applied. [By default this is 1]</param> /// <param name="borderType">The pixel extrapolation method. [By default this is BorderType.Constant]</param> /// <param name="borderValue">The border value in case of a constant border. The default value has a special meaning. [By default this is CvCpp.MorphologyDefaultBorderValue()]</param> #endif public static void MorphologyEx(Mat src, Mat dst, MorphologyOperation op, Mat element, CvPoint? anchor = null, int iterations = 1, BorderType borderType = BorderType.Constant, CvScalar? borderValue = null) { if (src == null) throw new ArgumentNullException("src"); if (dst == null) throw new ArgumentNullException("dst"); if (element == null) throw new ArgumentNullException("element"); CvPoint _anchor = anchor.GetValueOrDefault(new CvPoint(-1, -1)); CvScalar _borderValue = borderValue.GetValueOrDefault(MorphologyDefaultBorderValue()); CppInvoke.cv_morphologyEx(src.CvPtr, dst.CvPtr, op, element.CvPtr, _anchor, iterations, borderType, _borderValue); }