internal static extern IntPtr cvCreateStructuringElementEx( int cols, int rows, int anchor_x, int anchor_y, StructuringElementShape shape, int[] values);
/// <summary> /// Initializes a new instance of the <see cref="IplConvKernel"/> class with the specified /// size, anchor, shape and optionally custom kernel values for the structuring element. /// </summary> /// <param name="cols">The width of the structuring element.</param> /// <param name="rows">The height of the structuring element.</param> /// <param name="anchorX">The x-coordinate of the anchor.</param> /// <param name="anchorY">The y-coordinate of the anchor.</param> /// <param name="shape">The shape of the structuring element.</param> /// <param name="values"> /// The kernel values that specify the custom shape of the structuring element, when /// <paramref name="shape"/> is equal to <see cref="StructuringElementShape.Custom"/>. /// </param> public IplConvKernel(int cols, int rows, int anchorX, int anchorY, StructuringElementShape shape, int[] values) : base(true) { var pKernel = NativeMethods.cvCreateStructuringElementEx(cols, rows, anchorX, anchorY, shape, values); SetHandle(pKernel); }
public StructuringElement(int size) { Size = size; Kernel = new int[size, size]; Shape = StructuringElementShape.Rectangle; fillKernel(); }
public StructuringElement(StructuringElementShape shape, int size) { if (size % 2 != 1 && size < 3) { throw new ArgumentException("Size should be odd and at least 3"); } Kernel = new int[size, size]; Size = size; Shape = shape; fillKernel(); }
/// <summary> /// Initializes a new instance of the <see cref="IplConvKernel"/> class with the specified /// size, anchor and shape for the structuring element. /// </summary> /// <param name="cols">The width of the structuring element.</param> /// <param name="rows">The height of the structuring element.</param> /// <param name="anchorX">The x-coordinate of the anchor.</param> /// <param name="anchorY">The y-coordinate of the anchor.</param> /// <param name="shape">The shape of the structuring element.</param> public IplConvKernel(int cols, int rows, int anchorX, int anchorY, StructuringElementShape shape) : this(cols, rows, anchorX, anchorY, shape, null) { }
/// <summary> /// /// </summary> /// <param name="shape"></param> /// <param name="ksize"></param> /// <param name="anchor"></param> /// <returns></returns> public static Mat GetStructuringElement(StructuringElementShape shape, Size ksize, Point anchor) { IntPtr matPtr = NativeMethods.imgproc_getStructuringElement((int)shape, ksize, anchor); return new Mat(matPtr); }
/// <summary> /// /// </summary> /// <param name="shape"></param> /// <param name="ksize"></param> /// <returns></returns> public static Mat GetStructuringElement(StructuringElementShape shape, Size ksize) { return GetStructuringElement(shape, ksize, new Point(-1, -1)); }