Exemplo n.º 1
0
        private void Button_TwoD_Click(object sender, System.EventArgs e)
        {
            Bitmap twoVBmp;

            ProcessFunctions.TwoDivision_Change(bitmap, out twoVBmp, trackBar_DV.Value);
            this.pictureBox_WorkPlace.Image = ToolFunctions.GetThumbnail((Bitmap)twoVBmp.Clone(), pictureBox_WorkPlace.Height, pictureBox_WorkPlace.Width) as Image;
        }
Exemplo n.º 2
0
        private void button_Sharpen_Click(object sender, EventArgs e)
        {
            Bitmap sharpenBmp;

            sharpenBmp = ProcessFunctions.SharpenFilter2(bitmap, trackBar_SV.Value);
            this.pictureBox_WorkPlace.Image = ToolFunctions.GetThumbnail((Bitmap)sharpenBmp.Clone(), pictureBox_WorkPlace.Height, pictureBox_WorkPlace.Width) as Image;
        }
Exemplo n.º 3
0
        private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
        {
            Console.WriteLine("Change");
            if (isChoosed == false)
            {
                MessageBox.Show("未选择图片");
            }
            label_funcName.Text = tabControl1.SelectedTab == null ? "empty" : tabControl1.SelectedTab.Text;
            if (tabControl1.SelectedTab == null)
            {
                return;
            }

            foreach (Control c in tabControl1.SelectedTab.Controls)
            {
                c.Enabled = isChoosed;
            }
            DialogResult dr = MessageBox.Show("是否保存修改结果?", "提示", MessageBoxButtons.OKCancel);

            if (dr == DialogResult.OK)
            {
                bitmap = new Bitmap(this.pictureBox_WorkPlace.Image);
            }
            else
            {
                this.pictureBox_WorkPlace.Image = ToolFunctions.GetThumbnail((Bitmap)bitmap.Clone(), pictureBox_WorkPlace.Height, pictureBox_WorkPlace.Width);
            }

            Page_Reset();
        }
Exemplo n.º 4
0
        private void button12_Click(object sender, EventArgs e)
        {
            Size  picSize = new Size();
            Image temp    = ToolFunctions.GetInitThumbnail((Bitmap)bitmap.Clone(), pictureBox1.Height, pictureBox1.Width, out picSize) as Image;

            this.pictureBox1.Width = picSize.Width;
            //this.pictureBox1.Location = new Point(14 + 1097 / 2 - picSize.Width / 2, 25);
            this.pictureBox1.Image       = temp;
            this.pictureBox1.MouseClick += new MouseEventHandler((o, me) =>
            {
                ProcessFunctions.test_01(bitmap, me.Location, pictureBox1.Size);
                Console.WriteLine("location of Point:" + me.Location.X + "," + me.Location.Y);
                Bitmap outBmp;
                ProcessFunctions.setMosaic(bitmap, me.Location, pictureBox1.Size, 0, out outBmp);
                this.pictureBox1.Image = ToolFunctions.GetThumbnail(outBmp, pictureBox1.Height, pictureBox1.Width);
                //Console.WriteLine(pictureBox1.Width);
            });
            this.pictureBox1.MouseMove += new MouseEventHandler((o, me) =>
            {
                Bitmap outBmp;
                ProcessFunctions.setMosaic(bitmap, me.Location, pictureBox1.Size, 0, out outBmp);
                this.pictureBox1.Image = ToolFunctions.GetThumbnail(outBmp, pictureBox1.Height, pictureBox1.Width);
                bitmap = new Bitmap(this.pictureBox1.Image);
            });
        }
Exemplo n.º 5
0
        private void button10_Click(object sender, EventArgs e)
        {
            Bitmap twoBmp;

            ProcessFunctions.TwoDivision_Change(bitmap, out twoBmp, 150);
            pictureBox2.Image = ToolFunctions.GetThumbnail((Bitmap)twoBmp.Clone(), pictureBox2.Height, pictureBox2.Width) as Image;
        }
Exemplo n.º 6
0
        private void Button_Mean_Filter_Click(object sender, System.EventArgs e)
        {
            Bitmap newBmp;

            ProcessFunctions.MeanFilter(noise_oldBmp, out newBmp);
            this.pictureBox_WorkPlace.Image = ToolFunctions.GetThumbnail((Bitmap)newBmp.Clone(), pictureBox_WorkPlace.Height, pictureBox_WorkPlace.Width) as Image;
            noise_oldBmp = newBmp;
        }
Exemplo n.º 7
0
        private void button4_Click(object sender, EventArgs e)
        {
            Bitmap dest;

            pictureBox1.Image = ToolFunctions.GetThumbnail((Bitmap)bitmap.Clone(), pictureBox1.Height, pictureBox1.Width) as Image;
            ProcessFunctions.Grey_Change(bitmap, out dest, -5);
            pictureBox2.Image       = ToolFunctions.GetThumbnail((Bitmap)dest.Clone(), pictureBox2.Height, pictureBox2.Width) as Image;
            pictureBox1.MouseClick += PictureBox1_MouseClick;
        }
Exemplo n.º 8
0
 //clean button
 private void button2_Click_1(object sender, EventArgs e)
 {
     if (isChoosed == false)
     {
         return;
     }
     pictureBox_WorkPlace.Image = ToolFunctions.GetThumbnail((Bitmap)bitmap.Clone(), pictureBox_WorkPlace.Height, pictureBox_WorkPlace.Width) as Image;
     gReal = Graphics.FromImage(pictureBox_WorkPlace.Image);
 }
Exemplo n.º 9
0
        private void button7_Click(object sender, EventArgs e)
        {
            Bitmap noiseBmp;

            ProcessFunctions.AddPepperSalt(bitmap, 0.2, 0.2, out noiseBmp);
            pictureBox1.Image = ToolFunctions.GetThumbnail((Bitmap)noiseBmp.Clone(), pictureBox1.Height, pictureBox1.Width) as Image;
            //Bitmap cleanBmp;
            //ProcessFunctions.MedianFilter(noiseBmp, out cleanBmp);
            //pictureBox2.Image = ToolFunctions.GetThumbnail((Bitmap)cleanBmp.Clone(), pictureBox2.Height, pictureBox2.Width) as Image;
        }
Exemplo n.º 10
0
        private void button3_Click(object sender, EventArgs e)
        {
            ProcessFunctions.Grey_Calculator(bmpHist, out maxPixel, ref countPixel);
            Grey_ScaleMapForm_Paint();
            pictureBox1.Image = ToolFunctions.GetThumbnail((Bitmap)bitmap.Clone(), pictureBox1.Height, pictureBox1.Width) as Image;
            Bitmap destB;

            ProcessFunctions.Balance(bitmap, out destB);
            pictureBox2.Image = ToolFunctions.GetThumbnail((Bitmap)destB.Clone(), pictureBox2.Height, pictureBox2.Width) as Image;
        }
Exemplo n.º 11
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (openFileDialog1.ShowDialog() == DialogResult.OK)
     {
         string path = openFileDialog1.FileName;
         bitmap            = (Bitmap)Image.FromFile(path);
         pictureBox1.Image = ToolFunctions.GetThumbnail((Bitmap)bitmap.Clone(), pictureBox1.Height, pictureBox1.Width) as Image;
         gReal             = Graphics.FromImage(pictureBox1.Image);
         pictureBox2.Image = pictureBox1.Image;
     }
 }
Exemplo n.º 12
0
        private void Get_Balance_Click(object sender, EventArgs e)
        {
            Button self = (Button)sender;
            Bitmap dbitmap;

            ProcessFunctions.Balance(bmpHist, out dbitmap);
            this.pictureBox_WorkPlace.Image = ToolFunctions.GetThumbnail((Bitmap)dbitmap.Clone(), pictureBox_WorkPlace.Height, pictureBox_WorkPlace.Width) as Image;
            //this.pictureBox_data.CreateGraphics().Clear(Color.White);
            ProcessFunctions.Grey_Calculator(dbitmap, out maxGreyPixel, ref countGreyPixel);
            Grey_Datagraphic_Layout();
        }
Exemplo n.º 13
0
 private void Reset_Click(object sender, EventArgs e)
 {
     if (isChoosed == false)
     {
         MessageBox.Show("未选择图片");
         return;
     }
     Page_Reset();
     bitmap = (Bitmap)origin_bmp.Clone();
     pictureBox_WorkPlace.Image = ToolFunctions.GetThumbnail((Bitmap)bitmap.Clone(), pictureBox_WorkPlace.Height, pictureBox_WorkPlace.Width) as Image;
 }
Exemplo n.º 14
0
        private void button9_Click(object sender, EventArgs e)
        {
            Bitmap SharpenBmp;

            ProcessFunctions.SharpenFilter1(bitmap, out SharpenBmp);
            pictureBox2.Image = ToolFunctions.GetThumbnail((Bitmap)SharpenBmp.Clone(), pictureBox2.Height, pictureBox2.Width) as Image;
            Bitmap SharpenBmp2 = ProcessFunctions.SharpenFilter2(bitmap, 10F);

            pictureBox1.Image = ToolFunctions.GetThumbnail((Bitmap)SharpenBmp2.Clone(), pictureBox1.Height, pictureBox1.Width) as Image;
            pictureBox3.Image = ToolFunctions.GetThumbnail((Bitmap)bitmap.Clone(), pictureBox3.Height, pictureBox3.Width) as Image;
        }
Exemplo n.º 15
0
        private void TrackBar_Grey_ValueChange(object sender, EventArgs e)
        {
            TrackBar self = (TrackBar)sender;
            Bitmap   dbitmap;

            ProcessFunctions.Grey_Change(bmpHist, out dbitmap, self.Value);
            this.pictureBox_WorkPlace.Image = ToolFunctions.GetThumbnail((Bitmap)dbitmap.Clone(), pictureBox_WorkPlace.Height, pictureBox_WorkPlace.Width) as Image;
            //this.pictureBox_data.CreateGraphics().Clear(Color.White);
            ProcessFunctions.Grey_Calculator(dbitmap, out maxGreyPixel, ref countGreyPixel);
            Grey_Datagraphic_Layout();
        }
Exemplo n.º 16
0
        private void button5_Click(object sender, EventArgs e)
        {
            Bitmap srcm;

            pictureBox1.Image = ToolFunctions.GetThumbnail((Bitmap)bitmap.Clone(), pictureBox1.Height, pictureBox1.Width) as Image;
            ProcessFunctions.Hsl_Change("s", -5, bitmap, out srcm);
            pictureBox2.Image = ToolFunctions.GetThumbnail((Bitmap)srcm.Clone(), pictureBox1.Height, pictureBox1.Width) as Image;
            Color c  = Color.FromArgb(15, 40, 200);
            Color c2 = ProcessFunctions.Hsl_Pixel_Change(c, "h", 24);

            //Console.WriteLine(hue + "," + sa + "," + l);
            Console.WriteLine(c.R + "," + c.G + "," + c.B + " ; " + c2.R + "," + c2.G + "," + c2.B);
            //pictureBox3.BackColor = Color.FromArgb(258, 2, -1);
        }
Exemplo n.º 17
0
        private void Button_Add_Pepper_Click(object sender, System.EventArgs e)
        {
            label_state.Text      = "Processing";
            label_state.BackColor = Color.Yellow;
            Button b = (Button)sender;

            b.Enabled = false;
            Bitmap newBmp;

            ProcessFunctions.AddPepperSalt(noise_oldBmp, ((float)trackBar_Pa.Value) / 10, ((float)trackBar_Pb.Value) / 10, out newBmp);
            this.pictureBox_WorkPlace.Image = ToolFunctions.GetThumbnail((Bitmap)newBmp.Clone(), pictureBox_WorkPlace.Height, pictureBox_WorkPlace.Width) as Image;
            noise_oldBmp          = newBmp;
            b.Enabled             = true;
            label_state.Text      = "Finish";
            label_state.BackColor = Color.Green;
        }
Exemplo n.º 18
0
        private void button8_Click(object sender, EventArgs e)
        {
            //for (int i = 0; i < 1000; i++)
            //{
            //    double x = ProcessFunctions.GaussNoise(0,1);
            //    if(Math.Abs(x)>=1)
            //        Console.WriteLine(x);
            //}
            Bitmap noiseBmp;

            ProcessFunctions.AddGaussSalt(bitmap, out noiseBmp, new GaussParam(0, 1, 32));
            pictureBox1.Image = ToolFunctions.GetThumbnail((Bitmap)noiseBmp.Clone(), pictureBox1.Height, pictureBox1.Width) as Image;
            Bitmap cleanBmp;

            ProcessFunctions.MeanFilter(noiseBmp, out cleanBmp);
            pictureBox2.Image = ToolFunctions.GetThumbnail((Bitmap)cleanBmp.Clone(), pictureBox2.Height, pictureBox2.Width) as Image;
        }
Exemplo n.º 19
0
        private void Hsi_H_ValueChanged(object sender, EventArgs e)
        {
            TrackBar self = (TrackBar)sender;
            Bitmap   dbitmap;

            HV = self.Value;
            if (1 == HSI_FLAG)
            {
                ProcessFunctions.Hsl_Change("h", HV, (Bitmap)Hsi_tempBmp.Clone(), out dbitmap);
            }
            else
            {
                Bitmap dbitmap1;
                ProcessFunctions.Hsl_Change("l", IV, (Bitmap)Hsi_bitmap.Clone(), out dbitmap1);
                Bitmap dbitmap2;
                ProcessFunctions.Hsl_Change("S", SV, (Bitmap)dbitmap1.Clone(), out dbitmap2);
                Hsi_tempBmp = dbitmap2;
                ProcessFunctions.Hsl_Change("h", HV, (Bitmap)Hsi_tempBmp.Clone(), out dbitmap);
            }
            this.pictureBox_WorkPlace.Image = ToolFunctions.GetThumbnail((Bitmap)dbitmap.Clone(), pictureBox_WorkPlace.Height, pictureBox_WorkPlace.Width) as Image;
            Hsi_nowBmp = dbitmap;
        }
Exemplo n.º 20
0
        private void button_Add_Gauss_Click(object sender, EventArgs e)
        {
            label_state.Text      = "Processing";
            label_state.BackColor = Color.Yellow;
            Button b = (Button)sender;

            b.Enabled = false;
            Bitmap     newBmp;
            GaussParam g = new GaussParam(((float)trackBar_Nu.Value) / 10, ((float)trackBar_Nd.Value) / 10, trackBar_Nk.Value);
            Task       t = new Task(() => {
                ProcessFunctions.AddGaussSalt(noise_oldBmp, out newBmp, g);
                this.pictureBox_WorkPlace.Image = ToolFunctions.GetThumbnail((Bitmap)newBmp.Clone(), pictureBox_WorkPlace.Height, pictureBox_WorkPlace.Width) as Image;
                noise_oldBmp = newBmp;
            });

            t.Start();
            t.Wait();

            b.Enabled             = true;
            label_state.Text      = "Finish";
            label_state.BackColor = Color.Green;
        }
Exemplo n.º 21
0
        private int OpenT()
        {
            String filename = "F:\\b.png";

            //Mat I = (Bitmap)Image.FromFile(filename);
            Mat I      = new Mat(filename, ImreadModes.Color);
            Mat X      = new Mat();
            Mat padded = new Mat();                 //以0填充输入图像矩阵
            //Cv2.GetOptimalDFTSize();
            int m = Cv2.GetOptimalDFTSize(I.Rows);
            int n = Cv2.GetOptimalDFTSize(I.Cols);


            //填充输入图像I,输入矩阵为padded,上方和左方不做填充处理
            Cv2.CopyMakeBorder(I, padded, 0, m - I.Rows, 0, n - I.Cols, BorderTypes.Constant);


            pictureBox1.Image = ToolFunctions.GetThumbnail(X.ToBitmap(), pictureBox1.Height, pictureBox1.Width);



            return(0);
        }
Exemplo n.º 22
0
        private void pictureBox2_Paint_MouseMove(object sender, MouseEventArgs e)
        {
            if (isChoosed == false)
            {
                return;
            }
            if (in_box_flag == 1 && pen_type == 0)
            {
                //Console.WriteLine(e.Location.X + "," + e.Location.Y + "  " + flag);
                if (lastP.X == -1)
                {
                    Console.WriteLine("in");
                    lastP = e.Location;
                    return;
                }
                else
                {
                    SolidBrush solidBrush = new SolidBrush(choose_color);

                    Pen pen = new Pen(solidBrush, trackBar_Paint.Value);


                    myDrawLine(pen, lastP, e.Location);

                    lastP = e.Location;
                }
            }
            if (in_box_flag == 1 && pen_type == 1)
            {
                Bitmap dstBmp;

                ProcessFunctions.setMosaic(bitmap, e.Location, pictureBox_WorkPlace.Size, trackBar_Paint.Value, out dstBmp);
                //Console.WriteLine("Image size:"+ this.pictureBox_WorkPlace.Image.Width);
                this.pictureBox_WorkPlace.Image = ToolFunctions.GetThumbnail((Bitmap)dstBmp.Clone(), pictureBox_WorkPlace.Height, pictureBox_WorkPlace.Width);
                bitmap = new Bitmap(this.pictureBox_WorkPlace.Image);
            }
        }
 public Form_ShowOrigin(Bitmap bitmap)
 {
     InitializeComponent();
     ori_bmp = bitmap;
     this.pictureBox1.Image = ToolFunctions.GetThumbnail((Bitmap)ori_bmp.Clone(), pictureBox1.Height, pictureBox1.Width);
 }