开发者

C# OpenCvSharp实现去除字母后面的杂线

开发者 https://www.devze.com 2023-11-19 11:12 出处:网络 作者: 天天代码码天天
目录效果项目代码效果 项目 代码 ///php <summary>/// Applies an adaptive threshold to an array./// </summary>/// <param name="src">Source 8-bit single-channel image.</pa
目录
  • 效果
  • 项目
  • 代码

效果

C# OpenCvSharp实现去除字母后面的杂线

项目

C# OpenCvSharp实现去除字母后面的杂线

代码

///php <summary>

/// Applies an adaptive threshold to an array.

/// </summary>

/// <param name="src">Source 8-bit single-channel image.</param>

/// <param name="dst">Destination image of the same size and the same type as src .</param>

/// <param name="maxValue">Non-zero value assigned to the pixels for which the condition is satisfied. See the details below.</param>

/// <param name="adaptiveMethod">Adaptive thresholding algorithm to use, ADAPTIVE_THRESH_MEAN_C or ADAPTIVE_THRESH_GAUSSIAN_C .</param>

/// <param name="thresholdType">Thresholding type that must be either THRESH_BINARY or THRESH_BINARY_INV .</param>

/// <param name="blockSize">Size of a pixel neighborhood that is used to calculate a threshold value for the pixel: 3, 5, 7, and so on.</param>

/// <param name="编程客栈c">Constant subtracted from the mean or weighted mean (see the details below). 

/// Normally, it is positive but may be zero or negative as well.</param>

public static void AdaptiveThreshold(InputArray src, OutputArray dst,double maxValue, AdaptiveThresholdTypes adaptiveMethod, ThresholdTypes thresholdType, int blockSize, double c)

using OpenCvSharp;
using System;
using System.Drawing;
using System.Windows.Forms;
 
namespace OpenCvSharp_Demo
{
    public partial class frmMain : Form
    {
        public frmMain()
        {
            InitializeComponent();
        }
 
        string image_path = 编程"";
 
        private void Form1_Load(object sender, EventArgs e)
        {
            image_path = "1.jpg";
            pictureBox1.Image = new Bitmap(image_path);
        }
 
        private void button2_Click(object sender, EventArgs e)
        {
 
            Mat gray = new Mat(image_path, ImreadModes.Grayscale);
 
            Mat binary = new Mat();
 
            Cv2.AdaptiveThreshold(~gray, binary, 255, AdaptiveThresholdTypes.MeanC, ThresholdTypes.Binary, 15, -2);
 
            Mat kernel = Cv2.GetStructur编程ingElement(MorphShapes.Rect, new OpenCvSharp.Sijavascriptze(4, 4), new OpenCvSharp.Point(-1, -1));
 
            //开运算
            Mat dst = new Mat();
            Cv2.MorphologyEx(binary, dst, MorphTypes.Open, kernel);
 
            pictureBox2.Image = new Bitmap(dst.ToMemoryStream());
 
        }
 
    }
}

以上就是C# OpenCvSharp实现去除字母后面的杂线的详细内容,更多关于C# OpenCvSharp去除字母杂线的资料请关注编程客栈(www.devze.com)其它相关文章!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号