internal static extern IntPtr cveRidgeDetectionFilterCreate( int ddepth, int dx, int dy, int ksize, int outDtype, double scale, double delta, Emgu.CV.CvEnum.BorderType borderType, ref IntPtr algorithm, ref IntPtr sharedPtr);
/// <summary> /// Create a Ridge detection filter. /// </summary> /// <param name="dDepthType">Specifies output image depth.</param> /// <param name="dChannels">Specifies output image channel.</param> /// <param name="dx">Order of derivative x</param> /// <param name="dy">Order of derivative y</param> /// <param name="ksize">Sobel kernel size</param> /// <param name="outDepthType">Converted format for output</param> /// <param name="outChannels">Converted format for output</param> /// <param name="scale">Optional scale value for derivative values</param> /// <param name="delta">Optional bias added to output</param> /// <param name="borderType">Pixel extrapolation method</param> public RidgeDetectionFilter( CvEnum.DepthType dDepthType = CvEnum.DepthType.Cv32F, int dChannels = 1, int dx = 1, int dy = 1, int ksize = 3, CvEnum.DepthType outDepthType = CvEnum.DepthType.Cv8U, int outChannels = 1, double scale = 1, double delta = 0, Emgu.CV.CvEnum.BorderType borderType = Emgu.CV.CvEnum.BorderType.Default) { _ptr = XImgprocInvoke.cveRidgeDetectionFilterCreate( CvInvoke.MakeType(dDepthType, dChannels), dx, dy, ksize, CvInvoke.MakeType(outDepthType, outChannels), scale, delta, borderType, ref _algorithm, ref _sharedPtr); }
/// <summary> /// Dilates the source image using the specified structuring element that determines the shape of a pixel neighborhood over which the maximum is taken /// The function supports the in-place mode. Dilation can be applied several (iterations) times. In case of color image each channel is processed independently /// </summary> /// <param name="src">Source image</param> /// <param name="element">Structuring element used for erosion. If it is IntPtr.Zero, a 3x3 rectangular structuring element is used</param> /// <param name="iterations">Number of times erosion is applied</param> /// <param name="borderType">Pixel extrapolation method</param> /// <param name="borderValue">Border value in case of a constant border </param> /// <param name="anchor">Position of the anchor within the element; default value (-1, -1) means that the anchor is at the element center.</param> /// <returns>Output image of the same size and type as <code>src</code>.</returns> /// <remarks> /// http://docs.opencv.org/2.4/modules/imgproc/doc/filtering.html?highlight=dilate#dilate /// C++: void dilate(InputArray src, OutputArray dst, InputArray kernel, Point anchor=Point(-1,-1), int iterations=1, int borderType=BORDER_CONSTANT, const Scalar& borderValue=morphologyDefaultBorderValue() ) /// Python: cv2.dilate(src, kernel[, dst[, anchor[, iterations[, borderType[, borderValue]]]]]) → dst /// C: void cvDilate(const CvArr* src, CvArr* dst, IplConvKernel* element = NULL, int iterations = 1 ) /// Python: cv.Dilate(src, dst, element=None, iterations=1) → None /// </remarks> public static IOutputArray Dilate(IInputArray src, IInputArray element = null, Point?anchor = null, int iterations = 1, Emgu.CV.CvEnum.BorderType borderType = BorderType.Constant, MCvScalar?borderValue = null) { if (!anchor.HasValue) { anchor = new Point(-1, -1); } if (!borderValue.HasValue) { borderValue = CvInvoke.MorphologyDefaultBorderValue; } Mat dst = new Mat(); CvInvoke.Dilate(src, dst, element, anchor.Value, iterations, borderType, borderValue.Value); return(dst); }
private void runFilterButton_Click(object sender, EventArgs e) { Bitmap pBoxImage; Image <Bgr, byte> inputImage; Image <Gray, Byte> grayImage; try { pBoxImage = new Bitmap(pictureBox1.Image); inputImage = new Image <Bgr, Byte>(pBoxImage); grayImage = inputImage.Convert <Gray, Byte>(); } catch (Exception ex) { MessageBox.Show(ex.Message); throw; } switch (filtersComboBox.SelectedIndex) { case 0: //Gaussian colorFlag = true; filterLabel1.Visible = false; int otherGaussKernal = 5; if (otherGaussKernal % 2 == 0) { gaussKernel--; //textBox1.Text = otherGaussKernal.ToString(); } inputImage._SmoothGaussian(otherGaussKernal); break; case 1: //Histogram Equalization colorFlag = true; inputImage._EqualizeHist(); break; case 2: //MorphClose colorFlag = true; Mat kernel = CvInvoke.GetStructuringElement(Emgu.CV.CvEnum.ElementShape.Cross, new Size(15, 15), new Point(1, 1)); Emgu.CV.CvEnum.MorphOp operation = Emgu.CV.CvEnum.MorphOp.Close; Point anchor = new Point(-1, -1); int iterations = 1; Emgu.CV.CvEnum.BorderType borderType = Emgu.CV.CvEnum.BorderType.Default; Emgu.CV.Structure.MCvScalar borderValue = new MCvScalar(); inputImage._MorphologyEx(operation, kernel, anchor, iterations, borderType, borderValue); break; case 3: //MorphCloseB&W colorFlag = false; //Image<Gray, Byte> grayImage = inputImage.Convert<Gray, Byte>(); Mat kernel1 = CvInvoke.GetStructuringElement(Emgu.CV.CvEnum.ElementShape.Cross, new Size(15, 15), new Point(1, 1)); Emgu.CV.CvEnum.MorphOp operation1 = Emgu.CV.CvEnum.MorphOp.Close; Point anchor1 = new Point(-1, -1); int iterations1 = 1; Emgu.CV.CvEnum.BorderType borderType1 = Emgu.CV.CvEnum.BorderType.Default; Emgu.CV.Structure.MCvScalar borderValue1 = new MCvScalar(); grayImage._MorphologyEx(operation1, kernel1, anchor1, iterations1, borderType1, borderValue1); break; case 4: //Monochrome colorFlag = false; break; case 5: //Canny colorFlag = false; double cannyThresh = 10; double cannyThreshLinking = 500; grayImage = grayImage.Canny(cannyThresh, cannyThreshLinking); break; case 6: //Laplace colorFlag = false; int laplaceApertureSize = 1; //grayImage = grayImage.Laplace(apertureSize); //grayImage.Laplace(apertureSize).ConvertFrom(); Image <Gray, float> cannyGrayImageFloat = grayImage.Laplace(laplaceApertureSize); grayImage = cannyGrayImageFloat.Convert <Gray, Byte>(); break; case 7: //Sobel colorFlag = false; int sobelXOrder = 1; int sobelYOrder = 1; int sobelApertureSize = 5; Image <Gray, float> sobelGrayImageFloat = grayImage.Sobel(sobelXOrder, sobelYOrder, sobelApertureSize); grayImage = sobelGrayImageFloat.Convert <Gray, Byte>(); break; case 8: //SmoothBilatral colorFlag = true; int kernelSize = 25; int colorSigma = 55; int spaceSigma = 55; inputImage = inputImage.SmoothBilatral(kernelSize, colorSigma, spaceSigma); break; case 9: //ThresholdAdaptive colorFlag = false; Emgu.CV.Structure.Gray maxValue = new Gray(150); AdaptiveThresholdType adaptiveType = AdaptiveThresholdType.GaussianC; ThresholdType thresholdType = ThresholdType.Binary; int blockSize = 3; Emgu.CV.Structure.Gray param1 = new Gray(); grayImage = grayImage.ThresholdAdaptive(maxValue, adaptiveType, thresholdType, blockSize, param1); break; case 10: //SmoothMedian colorFlag = true; int smoothMedianSize = 25; inputImage = inputImage.SmoothMedian(smoothMedianSize); break; case 11: //CLAHE colorFlag = true; IInputArray CLAHEsrc = inputImage.GetOutputArray(); double CLAHEClipLimit = 40; Size CLAHETileGridSize = new System.Drawing.Size(8, 8); OutputArray CLAHEdst; Emgu.CV.CvInvoke.CLAHE(CLAHEsrc, CLAHEClipLimit, CLAHETileGridSize, CLAHEdst); break; default: MessageBox.Show("No filter selected, or failure occured"); break; } filterPictureBox.SizeMode = PictureBoxSizeMode.Zoom; if (colorFlag) { filterPictureBox.Image = inputImage.ToBitmap(); } else { filterPictureBox.Image = grayImage.ToBitmap(); } }