RemoveBg() public static méthode

去除背景
public static RemoveBg ( Bitmap img, int dgGrayValue ) : Image
img System.Drawing.Bitmap 原图片
dgGrayValue int 前景背景分界灰度值
Résultat Image
Exemple #1
0
        /// <summary>
        /// 去背景
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_bg_Click(object sender, EventArgs e)
        {
            Image img_noise = (Image)pb_grey.Image.Clone();
            //得到灰度图像前景色临界值

            // img_noise = ccccccmd.ImageHelper.RemoveBlock(img_noise,2);//报错
            //int v = ImageProcess.GetDgGrayValue(img_noise);
            int v = ImageProcess.ComputeThresholdValue((Bitmap)img_noise);
            //Image test = ImageProcess.RemoveBg((Bitmap)img_noise ,v );
            // int v2 = Test.ImageProcess.GetDgGrayValue(img_noise);
            Image img_bg = ImageProcess.RemoveBg((Bitmap)img_noise, v); //-----------去背景,内存法

            imgBged = Image2Num((Bitmap)img_bg);
            WriteToFile(imgBged, "experiment\\" + Path.GetFileNameWithoutExtension(imgurl) + "_bged.txt");
            pb_bg.Image = img_bg;
        }