/// <summary> /// Applies an advanced morphological operation to an image. /// </summary> /// <param name="src">Source image. CV_8UC1 and CV_8UC4 source types are supported.</param> /// <param name="dst">Destination image with the same size and type as src.</param> /// <param name="op">Type of morphological operation</param> /// <param name="kernel">Structuring element.</param> /// <param name="buf1"></param> /// <param name="buf2"></param> /// <param name="anchor">Position of an anchor within the element. /// The default value Point(-1, -1) means that the anchor is at the element center.</param> /// <param name="iterations">Number of times erosion and dilation to be applied.</param> /// <param name="stream">Stream for the asynchronous version.</param> public static void MorphologyEx( GpuMat src, GpuMat dst, MorphologyOperation op, Mat kernel, GpuMat buf1, GpuMat buf2, Point?anchor = null, int iterations = 1, Stream stream = null) { ThrowIfGpuNotAvailable(); if (src == null) { throw new ArgumentNullException(nameof(src)); } if (dst == null) { throw new ArgumentNullException(nameof(dst)); } if (kernel == null) { throw new ArgumentNullException(nameof(kernel)); } if (buf1 == null) { throw new ArgumentNullException(nameof(buf1)); } if (buf2 == null) { throw new ArgumentNullException(nameof(buf2)); } src.ThrowIfDisposed(); dst.ThrowIfDisposed(); kernel.ThrowIfDisposed(); buf1.ThrowIfDisposed(); buf2.ThrowIfDisposed(); Point anchor0 = anchor.GetValueOrDefault(new Point(-1, -1)); NativeMethods.gpu_morphologyEx2(src.CvPtr, dst.CvPtr, (int)op, kernel.CvPtr, buf1.CvPtr, buf2.CvPtr, anchor0, iterations, Cv2.ToPtr(stream)); }
/// <summary> /// Applies an advanced morphological operation to an image. /// </summary> /// <param name="src">Source image. CV_8UC1 and CV_8UC4 source types are supported.</param> /// <param name="dst">Destination image with the same size and type as src.</param> /// <param name="op">Type of morphological operation</param> /// <param name="kernel">Structuring element.</param> /// <param name="anchor">Position of an anchor within the element. /// The default value Point(-1, -1) means that the anchor is at the element center.</param> /// <param name="iterations">Number of times erosion and dilation to be applied.</param> public static void MorphologyEx( GpuMat src, GpuMat dst, MorphologyOperation op, Mat kernel, Point?anchor = null, int iterations = 1) { ThrowIfGpuNotAvailable(); if (src == null) { throw new ArgumentNullException("src"); } if (dst == null) { throw new ArgumentNullException("dst"); } if (kernel == null) { throw new ArgumentNullException("kernel"); } src.ThrowIfDisposed(); dst.ThrowIfDisposed(); kernel.ThrowIfDisposed(); Point anchor0 = anchor.GetValueOrDefault(new Point(-1, -1)); NativeMethods.gpu_morphologyEx1(src.CvPtr, dst.CvPtr, (int)op, kernel.CvPtr, anchor0, iterations); }
/// <summary> /// 高度なモルフォロジー変換を行います. /// </summary> /// <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> /// <returns>src と同じサイズ,同じ型の出力画像</returns> #else /// <summary> /// Performs advanced morphological transformations /// </summary> /// <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> /// <returns>Destination image. It will have the same size and the same type as src</returns> #endif public Mat MorphologyEx(MorphologyOperation op, InputArray element, CvPoint? anchor = null, int iterations = 1, BorderType borderType = BorderType.Constant, CvScalar? borderValue = null) { var dst = new Mat(); Cv2.MorphologyEx(this, dst, op, element, anchor, iterations, borderType, borderValue); return dst; }
public static extern void cvMorphologyEx(IntPtr src, IntPtr dst, IntPtr temp, IntPtr element, MorphologyOperation operation, int iterations);
/// <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); }
/// <summary> /// Applies an advanced morphological operation to an image. /// </summary> /// <param name="src">Source image. CV_8UC1 and CV_8UC4 source types are supported.</param> /// <param name="dst">Destination image with the same size and type as src.</param> /// <param name="op">Type of morphological operation</param> /// <param name="kernel">Structuring element.</param> /// <param name="buf1"></param> /// <param name="buf2"></param> /// <param name="anchor">Position of an anchor within the element. /// The default value Point(-1, -1) means that the anchor is at the element center.</param> /// <param name="iterations">Number of times erosion and dilation to be applied.</param> /// <param name="stream">Stream for the asynchronous version.</param> public static void MorphologyEx( GpuMat src, GpuMat dst, MorphologyOperation op, Mat kernel, GpuMat buf1, GpuMat buf2, Point? anchor = null, int iterations = 1, Stream stream = null) { ThrowIfGpuNotAvailable(); if (src == null) throw new ArgumentNullException("src"); if (dst == null) throw new ArgumentNullException("dst"); if (kernel == null) throw new ArgumentNullException("kernel"); if (buf1 == null) throw new ArgumentNullException("buf1"); if (buf2 == null) throw new ArgumentNullException("buf2"); src.ThrowIfDisposed(); dst.ThrowIfDisposed(); kernel.ThrowIfDisposed(); buf1.ThrowIfDisposed(); buf2.ThrowIfDisposed(); Point anchor0 = anchor.GetValueOrDefault(new Point(-1, -1)); NativeMethods.gpu_morphologyEx2(src.CvPtr, dst.CvPtr, (int)op, kernel.CvPtr, buf1.CvPtr, buf2.CvPtr, anchor0, iterations, Cv2.ToPtr(stream)); }