OpenCV image edge extraction (3) - Laplance operator edge extraction principle and OpenCV API usage (C#)

Insert image description here
Theory: In the second derivative, the value at the maximum change is zero, that is, the edge is zero. Through second-order derivative calculation, according to this theory, we can calculate the second-order derivative of the image and extract the edge.

API

public static void Laplacian(InputArray src, OutputArray dst, MatType ddepth, int ksize = 1, double scale = 1, double delta = 0, BorderTypes borderType = BorderTypes.Reflect101);

Insert image description here
Demo:

if (fileDialog.ShowDialog() == DialogResult.OK)
{
    
    

    picFile = fileDialog.FileName;
    inputMat = Cv2.ImRead(picFile, ImreadModes.Grayscale);                
    outMat = new Mat(new Size(inputMat.Cols, inputMat.Rows), inputMat.Type());
    Cv2.Laplacian(inputMat, outMat, MatType.CV_8UC1);
    picBox_Display.Image = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(inputMat);
    picBox_After.Image = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(outMat);
}

Insert image description here

Additional notes:
The OpenCV library used in .NET in this case is OpenCvSharp4

OpenCv library for .NET environment

Guess you like

Origin blog.csdn.net/weixin_40671962/article/details/127079254