C# OpenCvSharp實(shí)現(xiàn)去除字母后面的雜線
效果
項(xiàng)目
代碼
/// <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.GetStructuringElement(MorphShapes.Rect, new OpenCvSharp.Size(4, 4), new OpenCvSharp.Point(-1, -1)); //開運(yùn)算 Mat dst = new Mat(); Cv2.MorphologyEx(binary, dst, MorphTypes.Open, kernel); pictureBox2.Image = new Bitmap(dst.ToMemoryStream()); } } }
以上就是C# OpenCvSharp實(shí)現(xiàn)去除字母后面的雜線的詳細(xì)內(nèi)容,更多關(guān)于C# OpenCvSharp去除字母雜線的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!
相關(guān)文章
vs2005中總是保留最近打開的項(xiàng)目和文件的記錄
這篇文章主要介紹了vs2005中總是保留最近打開的項(xiàng)目和文件的記錄,需要的朋友可以參考下2016-06-06C#不改變圖像長(zhǎng)寬比例調(diào)整圖像大小方式
文章介紹了在UI顯示圖片時(shí),當(dāng)容器大小固定而圖片尺寸大于容器時(shí),可以通過編碼計(jì)算長(zhǎng)寬來重繪圖像,以確保圖像的長(zhǎng)寬比例不變,C#代碼示例展示了如何在Winform前端實(shí)現(xiàn)這一功能2025-01-01C#使用Microsoft消息隊(duì)列(MSMQ)的示例詳解
Microsoft?Message?Queuing?(MSMQ)?是在多個(gè)不同的應(yīng)用之間實(shí)現(xiàn)相互通信的一種異步傳輸模式,本文主要介紹了C#如何使用Microsoft消息隊(duì)列,需要的可以了解下2024-01-01Unity實(shí)現(xiàn)簡(jiǎn)單虛擬搖桿
這篇文章主要為大家詳細(xì)介紹了Unity實(shí)現(xiàn)簡(jiǎn)單虛擬搖桿,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-04-04C#內(nèi)置隊(duì)列類Queue用法實(shí)例
這篇文章主要介紹了C#內(nèi)置隊(duì)列類Queue用法,實(shí)例分析了C#內(nèi)置隊(duì)列的添加、移除等相關(guān)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-04-04