private void unsharp_button_Click(object sender, EventArgs e)
        {
            g = this.CreateGraphics();
            g.Clear(this.BackColor);

            int    mask_size = Convert.ToInt32(unsharp_mask_size_textBox.Text);
            double sigma     = Convert.ToDouble(unsharp_sigma_textBox.Text);
            double k         = Convert.ToDouble(unsharp_k_textBox.Text);

            // #1 Smooth the original image using Gaussian filter [Option1]
            int          filter_width  = mask_size;
            int          filter_height = mask_size;
            post_process p             = post_process.nothing;

            // pic = op.linearFilter(op.padding(pic, filter_width, filter_height), op.gaussianFilter_1(mask_size, sigma), filter_width / 2, filter_height / 2, p);

            // #2 Subtract the smoothed image from the original
            // pic_3 is the original image
            pic_3 = new Bitmap(filename);
            //Tuple<int[], int> hist_data =
            op.subtract(pic, pic_3, g);
            // so that Mask im >> pic_3 , blurred >> pic_1 .

            // #3 3.	Add a weighted portion from the mask to the original image
            // K × Mask(x,y)
            //op.multiplication(pic_3, k);
            pic = new Bitmap(filename);
            pic = op.unsharp_add(pic, pic_3, k);

            pic_3 = new Bitmap(filename);
            g.DrawImage(pic_3, 650, 200, pic_3.Width, pic_3.Height);
            g.DrawImage(pic, 50, 200, pic.Width, pic.Height);
            pic.Save("d:\\IM\\unsharp.png");
        }
        private void edge_detection_button_Click(object sender, EventArgs e)
        {
            g = this.CreateGraphics();
            g.Clear(this.BackColor);

            int          direction     = Convert.ToInt32(direction_textBox.Text);
            int          filter_width  = 3;
            int          filter_height = 3;
            post_process p             = post_process.normalization;

            // pic = op.linearFilter(op.padding(pic, filter_width, filter_height), op.edgeDetection_filter(direction), filter_width / 2, filter_height / 2, p);
            pic_2 = new Bitmap(filename);
            g.DrawImage(pic_2, 650, 200, pic_2.Width, pic_2.Height);
            g.DrawImage(pic, 50, 200, pic.Width, pic.Height);
            pic.Save("d:\\IM\\edge.png");
        }
        private void laplacian_sharpening_button_Click(object sender, EventArgs e)
        {
            g = this.CreateGraphics();
            g.Clear(this.BackColor);

            int          filter_width  = 3;
            int          filter_height = 3;
            post_process p             = post_process.cutoff;

            op.linearFilter(op.padding(pic, filter_width, filter_height), op.laplacian_filter(), filter_width / 2, filter_height / 2, p, g, 0);
            //pic = op.laplacian_sharping(op.padding(pic, filter_width, filter_height), op.laplacian_filter());
            pic_2 = new Bitmap(filename);
            g.DrawImage(pic_2, 650, 200, pic_2.Width, pic_2.Height);
            g.DrawImage(pic, 50, 200, pic.Width, pic.Height);
            pic.Save("d:\\IM\\laplacian.png");
        }
        private void mean_filter_button_Click(object sender, EventArgs e)
        {
            g = this.CreateGraphics();
            g.Clear(this.BackColor);
            int          origX         = Convert.ToInt32(mean_origX_textBox.Text);
            int          origY         = Convert.ToInt32(mean_origY_textBox.Text);
            int          filter_width  = Convert.ToInt32(mean_width_textBox.Text);
            int          filter_height = Convert.ToInt32(mean_height_textBox.Text);
            post_process p             = post_process.nothing;

            op.linearFilter(op.padding(pic, filter_width, filter_height), op.meanFilter(filter_width, filter_height), origX, origY, p, g, 0);
            //pic_2 = new Bitmap(filename);
            //g.DrawImage(pic_2, 650, 200, pic_2.Width, pic_2.Height);
            //g.DrawImage(pic, 50, 200, pic.Width, pic.Height);
            //pic.Save("d:\\IM\\mean_filter.png");
        }
        private void gaussian_filter_1_button_Click(object sender, EventArgs e)
        {
            g = this.CreateGraphics();
            g.Clear(this.BackColor);

            int          mask_size     = Convert.ToInt32(mask_size_1_textBox.Text);
            double       sigma         = Convert.ToDouble(sigma_1_textBox.Text);
            int          filter_width  = mask_size;
            int          filter_height = mask_size;
            post_process p             = post_process.nothing;

            op.linearFilter(op.padding(pic, filter_width, filter_height), op.gaussianFilter_1(mask_size, sigma), filter_width / 2, filter_height / 2, p, g, 0);

            /*
             * pic_2 = new Bitmap(filename);
             * g.DrawImage(pic_2, 650, 200, pic_2.Width, pic_2.Height);
             * g.DrawImage(pic, 50, 200, pic.Width, pic.Height);
             * pic.Save("d:\\IM\\gaussian_1.png");
             * */
        }
        private void gaussian_filter_2_button_Click(object sender, EventArgs e)
        {
            g = this.CreateGraphics();
            g.Clear(this.BackColor);

            double sigma = Convert.ToDouble(sigma_2_textBox.Text);
            //Compute Mask Size
            int    n         = (int)(3.7 * sigma - 0.5);
            double mask_size = 2 * n + 1;

            int          filter_width  = (int)mask_size;
            int          filter_height = (int)mask_size;
            post_process p             = post_process.nothing;

            op.linearFilter(op.padding(pic, filter_width, filter_height), op.gaussianFilter_2(sigma), filter_width / 2, filter_height / 2, p, g, 0);

            /*
             * pic_2 = new Bitmap(filename);
             * g.DrawImage(pic_2, 650, 200, pic_2.Width, pic_2.Height);
             * g.DrawImage(pic, 50, 200, pic.Width, pic.Height);
             * pic.Save("d:\\IM\\gaussian_2.png");
             * */
        }