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; }
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; }
private void Grey_Page_Init() { greyReset(); ProcessFunctions.Grey_Calculator(bmpHist, out maxGreyPixel, ref countGreyPixel); this.pictureBox_WorkPlace.MouseClick += PictureBox2_MouseClick_GetColor; Grey_Datagraphic_Layout(); }
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; }
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); }); }
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; }
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; }
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; }
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; }
private void button6_Click(object sender, EventArgs e) { pictureBox3.Image = bitmap; for (int i = 0; i < 72; i++) { Color color = ProcessFunctions.HSL2RGB(5 * i, 0.5, 0.5); SolidBrush solidBrush = new SolidBrush(color); Pen pen = new Pen(solidBrush, 2); Graphics g2 = pictureBox1.CreateGraphics(); g2.DrawLine(pen, new Point(i * 4 + 2, 20), new Point(i * 4 + 2, 200)); } int maxHuePixel; int[] countHuePixel = new int[73]; ProcessFunctions.Hue_Calculator(bitmap, out maxHuePixel, ref countHuePixel); Graphics g = pictureBox2.CreateGraphics(); Pen curPen = new Pen(Brushes.Black, 1); g.DrawString("色调直方图", new Font("New Timer", 15), Brushes.Black, new Point(139, 10)); g.DrawLine(curPen, 50, 240, 360, 240); g.DrawLine(curPen, 50, 240, 50, 30); g.DrawLine(curPen, 110, 240, 110, 242); g.DrawLine(curPen, 160, 240, 160, 242); g.DrawLine(curPen, 210, 240, 210, 242); g.DrawLine(curPen, 260, 240, 260, 242); g.DrawLine(curPen, 310, 240, 310, 242); g.DrawLine(curPen, 360, 240, 360, 242); g.DrawString("0", new Font("New Timer", 8), Brushes.Black, new PointF(56, 242)); g.DrawString("60", new Font("New Timer", 8), Brushes.Black, new PointF(102, 242)); g.DrawString("120", new Font("New Timer", 8), Brushes.Black, new PointF(149, 242)); g.DrawString("180", new Font("New Timer", 8), Brushes.Black, new PointF(199, 242)); g.DrawString("240", new Font("New Timer", 8), Brushes.Black, new PointF(249, 242)); g.DrawString("300", new Font("New Timer", 8), Brushes.Black, new PointF(299, 242)); g.DrawString("360", new Font("New Timer", 8), Brushes.Black, new PointF(349, 242)); g.DrawLine(curPen, 48, 40, 50, 40); g.DrawString("0", new Font("New Timer", 8), Brushes.Black, new PointF(34, 234)); g.DrawString(maxHuePixel.ToString(), new Font("New Timer", 8), Brushes.Black, new PointF(18, 34)); double temp = 0; for (int i = 0; i < 73; i++) { temp = 200.0 * countHuePixel[i] / maxHuePixel; if (temp > 199) { Console.WriteLine(i); } SolidBrush solidBrush = new SolidBrush(ProcessFunctions.HSL2RGB(5 * i, 0.5, 0.5)); Pen ContPen = new Pen(solidBrush, 2); g.DrawLine(ContPen, (float)(60 + 3.5 * i), 240, (float)(60 + 3.5 * i), 240 - (int)temp); } curPen.Dispose(); }
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; }
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(); }
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(); }
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); }
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; }
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; }
private void Hsi_Datapicturebox_Layout() { ProcessFunctions.Hue_Calculator(Hsi_nowBmp, out maxHuePixel, ref countHuePixel); Graphics g = tabPage_Hsi.CreateGraphics(); g.Clear(Color.White); int offset_Y = 350; Pen curPen = new Pen(Brushes.Black, 2); g.DrawString("色调直方图", new Font("New Timer", 15), Brushes.Black, new Point(139, 10 + offset_Y)); g.DrawLine(curPen, 50, 240 + offset_Y, 350, 240 + offset_Y); g.DrawLine(curPen, 50, 240 + offset_Y, 50, 30 + offset_Y); g.DrawLine(curPen, 100, 240 + offset_Y, 100, 242 + offset_Y); g.DrawLine(curPen, 150, 240 + offset_Y, 150, 242 + offset_Y); g.DrawLine(curPen, 200, 240 + offset_Y, 200, 242 + offset_Y); g.DrawLine(curPen, 250, 240 + offset_Y, 250, 242 + offset_Y); g.DrawLine(curPen, 300, 240 + offset_Y, 300, 242 + offset_Y); g.DrawLine(curPen, 350, 240 + offset_Y, 350, 242 + offset_Y); g.DrawString("0", new Font("New Timer", 8), Brushes.Black, new PointF(46, 242 + offset_Y)); g.DrawString("60", new Font("New Timer", 8), Brushes.Black, new PointF(92, 242 + offset_Y)); g.DrawString("120", new Font("New Timer", 8), Brushes.Black, new PointF(139, 242 + offset_Y)); g.DrawString("180", new Font("New Timer", 8), Brushes.Black, new PointF(189, 242 + offset_Y)); g.DrawString("240", new Font("New Timer", 8), Brushes.Black, new PointF(239, 242 + offset_Y)); g.DrawString("300", new Font("New Timer", 8), Brushes.Black, new PointF(289, 242 + offset_Y)); g.DrawString("360", new Font("New Timer", 8), Brushes.Black, new PointF(339, 242 + offset_Y)); g.DrawLine(curPen, 48, 40 + offset_Y, 50, 40 + offset_Y); g.DrawString("0", new Font("New Timer", 8), Brushes.Black, new PointF(34, 234 + offset_Y)); g.DrawString(maxHuePixel.ToString(), new Font("New Timer", 8), Brushes.Black, new PointF(18, 34 + offset_Y)); double temp = 0; for (int i = 0; i < 73; i++) { temp = 200.0 * countHuePixel[i] / maxHuePixel; if (temp > 199) { Console.WriteLine(i); } SolidBrush solidBrush = new SolidBrush(ProcessFunctions.HSL2RGB(5 * i, 0.5, 0.5)); Pen ContPen = new Pen(solidBrush, 2); g.DrawLine(ContPen, (float)(60 + 3.5 * i), 240 + offset_Y, (float)(60 + 3.5 * i), 240 - (int)temp + offset_Y); } curPen.Dispose(); }
private bool GetColor(MouseEventArgs e, out Color c) { int bw = bitmap.Width * pictureBox_WorkPlace.Height / bitmap.Height; int pw = pictureBox_WorkPlace.Width; int offset_x = (pw - bw) / 2; Point clickp = new Point(e.Location.X - offset_x, e.Location.Y); if (clickp.X < 0 || clickp.X > bw) { c = Color.White; return(false); } //e.Location.X -= offset_x; Console.WriteLine(bw); Console.WriteLine(pw); c = ProcessFunctions.GetColor(MousePosition); return(true); }
private void PictureBox1_MouseClick(object sender, MouseEventArgs e) { // w1/h1=w/h h1=H w1=H*w/h int bw = bitmap.Width * pictureBox1.Height / bitmap.Height; int pw = pictureBox1.Width; int offset_x = (pw - bw) / 2; Point clickp = new Point(e.Location.X - offset_x, e.Location.Y); if (clickp.X < 0 || clickp.X > bw) { return; } //e.Location.X -= offset_x; Console.WriteLine(bw); Console.WriteLine(pw); Color c = ProcessFunctions.GetColor(MousePosition); this.pictureBox3.BackColor = c; }
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; }
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; }
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); } }