private void медианныйToolStripMenuItem_Click(object sender, EventArgs e) { MedianFilter filter = new MedianFilter(); Bitmap resultImage = filter.create_new_bitmap(5, image); pictureBox2.Image = resultImage; pictureBox2.Refresh(); }
private void светящиесяКраяToolStripMenuItem_Click(object sender, EventArgs e) { MedianFilter filter = new MedianFilter(); Bitmap resultImage = filter.create_new_bitmap(5, image); float[,] kerx = new float[3, 3] { { -1, -1, -1 }, { 0, 0, 0 }, { 1, 1, 1 } }; float[,] kery = new float[3, 3] { { -1, 0, 1 }, { -1, 0, 1 }, { -1, 0, 1 } }; Filters filter1 = new PrutFilter(kerx); Bitmap resultImage1 = filter1.processImage(resultImage); pictureBox2.Image = resultImage; Filters filter2 = new PrutFilter(kery); Bitmap resultImage2 = filter2.processImage(resultImage); Bitmap res = PrutFunc(resultImage1, resultImage2); Bitmap PrutFunc(Bitmap a, Bitmap b) { Bitmap resImage = new Bitmap(a.Width, a.Height); for (int i = 0; i < a.Width; i++) { for (int j = 0; j < a.Height; j++) { Color sourceColor = a.GetPixel(i, j); Color sourceColor1 = b.GetPixel(i, j); double intensR = Math.Sqrt((double)(Math.Pow((Int32)sourceColor.R, 2) + Math.Pow((Int32)sourceColor1.R, 2))); double intensG = Math.Sqrt((double)(Math.Pow((Int32)sourceColor.G, 2) + Math.Pow((Int32)sourceColor1.G, 2))); double intensB = Math.Sqrt((double)(Math.Pow((Int32)sourceColor.B, 2) + Math.Pow((Int32)sourceColor1.B, 2))); double intensity = intensR + intensG + intensB; Color resColor = Color.FromArgb(Clamp((Int32)(intensity), 0, 255), Clamp((Int32)(intensity), 0, 255), Clamp((Int32)(intensity), 0, 255)); resImage.SetPixel(i, j, resColor); } } return(resImage); } maxfilter filter3 = new maxfilter(); resultImage = filter3.processimage(res); pictureBox2.Image = resultImage; pictureBox2.Refresh(); }