Exemplo n.º 1
0
        public static void AddGaussSalt(Bitmap srcBmp, out Bitmap dstBmp, GaussParam gp)
        {
            // Bitmap pic = (Bitmap)Bitmap.FromFile(filename, false);
            dstBmp = srcBmp;
                        int width  = dstBmp.Width;
            int             height = dstBmp.Height;

            for (int i = 0; i < height; i++)
            {
                for (int j = 0; j < width; j++)
                {
                    int   noise  = (int)(GaussNoise(gp.u, gp.d) * gp.k);
                    Color noiseC = dstBmp.GetPixel(j, i);
                    Color color  = Color.FromArgb(valChange(noiseC.R, noise), valChange(noiseC.G, noise), valChange(noiseC.B, noise));
                    dstBmp.SetPixel(j, i, color);
                }
            }
        }
Exemplo n.º 2
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;
        }