コード例 #1
0
 /// <summary>
 /// 字模学习入库
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btn_CodeStudy_Click(object sender, EventArgs e)
 {
     if (cutResult != null)
     {
         string[]      zimos   = File.ReadAllLines(zimoPath);
         string        zimo    = string.Empty;
         StringBuilder sb      = new StringBuilder();
         string[]      stuCode = new string[] { txt1.Text.Trim(), txt2.Text.Trim(), txt3.Text.Trim(), txt4.Text.Trim(), txt5.Text.Trim(), txt6.Text.Trim(), txt7.Text.Trim(), txt8.Text.Trim() };
         for (int i = 0; i < cutResult.Count; i++)
         {
             if (!string.IsNullOrEmpty(stuCode[i]))
             {
                 ImageProcess.WriteZimo(cutResult[i], zimoPath, stuCode[i]);
             }
         }
         txt1.Text = "";
         txt2.Text = "";
         txt3.Text = "";
         txt4.Text = "";
         txt5.Text = "";
         txt6.Text = "";
         txt7.Text = "";
         txt8.Text = "";
     }
     else
     {
         MessageBox.Show("验证码分割过程错误!");
     }
 }
コード例 #2
0
        /// <summary>
        /// 去噪点
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_noise_Click(object sender, EventArgs e)
        {
            Image img_noise = ImageProcess.RemoveNoise((Bitmap)pb_bg.Image.Clone(), noiseThreshold);

            imgNoised      = Image2Num((Bitmap)img_noise);
            pb_noise.Image = img_noise;
        }
コード例 #3
0
        /// <summary>
        /// 二值化处理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_binary_Click(object sender, EventArgs e)
        {
            //去噪处理后的图片
            Image imgBinary = (Image)pb_noise.Image.Clone();

            imgBinary             = ImageProcess.Binary((Bitmap)imgBinary);
            imgBinaried           = Image2Num((Bitmap)imgBinary);
            pb_noise_binary.Image = imgBinary;
        }
コード例 #4
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();

            //得到灰度图像前景色临界值
            int   v      = ImageProcess.ComputeThresholdValue((Bitmap)img_noise);
            Image img_bg = ImageProcess.RemoveBg((Bitmap)img_noise, v);

            imgBged     = Image2Num((Bitmap)img_bg);
            pb_bg.Image = img_bg;
        }
コード例 #5
0
        /// <summary>
        /// 识别
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_recognize_Click(object sender, EventArgs e)
        {
            Image  img2 = (Image)pborigin.Image.Clone();
            string sb   = ImageProcess.GetYZMCode(img2, zimoPath, noiseThreshold, 20, 30, graytype, isFourChars, minWidth);

            char[] cs = sb.ToCharArray();
            for (int i = 0; i < 8; i++)
            {
                TextBox tb = this.Controls.Find("txt" + (i + 1), true).FirstOrDefault() as TextBox;
                if (cs.Length > i)
                {
                    tb.Text = cs[i].ToString();
                }
                else
                {
                    tb.Text = "";
                }
            }
        }
コード例 #6
0
        /// <summary>
        /// 三种方式下灰度
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_gray_Click(object sender, EventArgs e)
        {
            Image img      = pborigin.Image;
            Image img_grey = (Image)img.Clone();

            imgOriginal = Image2Num((Bitmap)img_grey);

            //灰度化处理
            //img_gray = ccccccmd.ImageHelper.Gray(img_gray, ccccccmd.ImageHelper.AlgorithmsType.AverageValue);//平均
            //img_gray = ccccccmd.ImageHelper.Gray(img_gray, ccccccmd.ImageHelper.AlgorithmsType.MaxValue );//最大值
            //img_gray = ccccccmd.ImageHelper.Gray(img_gray, ccccccmd.ImageHelper.AlgorithmsType.WeightAverage);//加权
            graytype = 2;
            if (rb_max.Checked)
            {
                graytype = 1;
            }
            if (rb_quanzhong.Checked)
            {
                graytype = 3;
            }
            img_grey      = ImageProcess.Gray((Bitmap)img_grey, graytype);
            imgGreied     = Image2Num((Bitmap)img_grey);
            pb_grey.Image = img_grey;
        }
コード例 #7
0
        private void btn_cutImage_Click(object sender, EventArgs e)
        {
            Image         img_cut = (Image)pb_noise_binary.Image.Clone();
            List <Bitmap> list    = ImageProcess.CutImage(img_cut, 20, 30, isFourChars, minWidth);

            cutResult = list;

            pb1.Image = list[0];
            if (list.Count >= 2)
            {
                pb2.Image = list[1];
            }
            else
            {
                pb2.Image = nullImg;
            }
            if (list.Count >= 3)
            {
                pb3.Image = list[2];
            }
            else
            {
                pb3.Image = nullImg;
            }
            if (list.Count >= 4)
            {
                pb4.Image = list[3];
            }
            else
            {
                pb4.Image = nullImg;
            }

            if (list.Count >= 5)
            {
                pb5.Image = list[4];
            }
            else
            {
                pb5.Image = nullImg;
            }
            if (list.Count >= 6)
            {
                pb6.Image = list[5];
            }
            else
            {
                pb6.Image = nullImg;
            }

            if (list.Count >= 7)
            {
                pb7.Image = list[6];
            }
            else
            {
                pb7.Image = nullImg;
            }

            if (list.Count >= 8)
            {
                pb8.Image = list[7];
            }
            else
            {
                pb8.Image = nullImg;
            }
        }