Esempio n. 1
0
 public bufferedLockBitmap EdgeMagnitude()
 {
     bufferedLockBitmap pic1 = NO.LinearFilter(this.ImageLockBitmap, gn.line_detect_vertical(), 3, 3, 1, 1, "abs");
     bufferedLockBitmap pic2 = NO.LinearFilter(this.ImageLockBitmap, gn.line_detect_Horizontal(), 3, 3, 1, 1, "abs");
     Bitmap temp = new Bitmap(this.ImageLockBitmap.Width, this.ImageLockBitmap.Height);
     bufferedLockBitmap bt = new bufferedLockBitmap(temp);
     bt.LockBits();
     double sumR = 0, sumG = 0, sumB = 0;
     for (int i = 0; i < this.ImageLockBitmap.Height; i++)
     {
         for (int j = 0; j < this.ImageLockBitmap.Width; j++)
         {
             sumR += (double)pic1.Getpixel(j, i).R + pic2.Getpixel(j, i).R;
             sumG += (double)pic1.Getpixel(j, i).G + pic2.Getpixel(j, i).G;
             sumB += (double)pic1.Getpixel(j, i).B + pic2.Getpixel(j, i).B;
             if (sumR > 255) sumR = 255;
             else if (sumR < 0) sumR = 0;
             if (sumG > 255) sumG = 255;
             else if (sumG < 0) sumG = 0;
             if (sumB > 255) sumB = 255;
             else if (sumB < 0) sumB = 0;
             bt.SetPixel(j, i, Color.FromArgb(Convert.ToInt32(sumR), Convert.ToInt32(sumG), Convert.ToInt32(sumB)));
             sumR = 0;
             sumG = 0;
             sumB = 0;
         }
     }
     bt.UnlockBits();
     this.ImageLockBitmap = bt;
     return this.ImageLockBitmap;
 }
        public Bitmap Addpictures(bufferedLockBitmap pic1, bufferedLockBitmap pic2, double fraction)
        {
            if (pic1.Width == pic2.Width && pic1.Height == pic2.Height)
            {
                temp = new Bitmap(pic1.Width, pic1.Height);
                bufferedLockBitmap r = new bufferedLockBitmap(temp);
                r.LockBits();
                int R, G, B = 0;
                double f;
                for (int i = 0; i < temp.Height; i++)
                {
                    for (int j = 0; j < temp.Width; j++)
                    {
                        f = ((((double)pic1.Getpixel(j, i).R)) * fraction) + (((double)pic2.Getpixel(j, i).R) * (1 - fraction));
                        R = Convert.ToInt32(f);
                        f = ((((double)pic1.Getpixel(j, i).G)) * fraction) + (((double)pic2.Getpixel(j, i).G) * (1 - fraction));
                        G = Convert.ToInt32(f);
                        f = ((((double)pic1.Getpixel(j, i).B)) * fraction) + (((double)pic2.Getpixel(j, i).B) * (1 - fraction));
                        B = Convert.ToInt32(f);
                        r.SetPixel(j, i, Color.FromArgb(R, G, B));
                    }
                }
                r.UnlockBits();
                return r.source;

            }
            else
                MessageBox.Show("picture 1 size is equal to picture 2 size");
            return temp;
        }
        public void drawing(bufferedLockBitmap pixel, Chart chart1)
        {
            int R, G, B;
            for (int i = 0; i < pixel.Height; i++)
            {
                for (int j = 0; j <pixel.Width; j++)
                {
                    R = pixel.Getpixel(j,i).R;
                    Rarray[R]++;
                    G = pixel.Getpixel(j, i).G;
                    Garray[G]++;
                    B = pixel.Getpixel(j, i).B;
                    Barray[B]++;
                }
            }
            chart1.Series["Red"].Points.Clear();
            chart1.Series["Green"].Points.Clear();
            chart1.Series["Blue"].Points.Clear();

            for (int w = 0; w < 256; w++)
            {
                chart1.Series["Red"].Points.AddXY(w, this.Rarray[w]);
                chart1.Series["Green"].Points.AddXY(w, this.Garray[w]);
                chart1.Series["Blue"].Points.AddXY(w, this.Barray[w]);

            }
            chart1.Series["Green"].ChartType = SeriesChartType.SplineArea;
            chart1.Series["Green"].Color = Color.Green;

            chart1.Series["Red"].ChartType = SeriesChartType.SplineArea;
            chart1.Series["Red"].Color = Color.Red;

            chart1.Series["Blue"].ChartType = SeriesChartType.SplineArea;
            chart1.Series["Blue"].Color = Color.Blue;
        }
Esempio n. 4
0
 public void setbt(Bitmap input)
 {
     this.selectedimage = new bufferedLockBitmap(input);
     pictureBox1.Image = input;
     pictureBox2.Image = input;
     this.selectedimage.LockBits();
     this.selectedimage.UnlockBits();
     op = new Pixel_logic__Operations(selectedimage);
 }
        /**
         * find 4 adjacent pixels
            X1 = floor (OldX)	; X2 = X1 + 1
            Y1 = floor (OldY)	; Y2 = Y1 + 1
            P1 = OrigBuf[X1,Y1] 	; P2 = OrigBuf[X2,Y1]
            P3 = OrigBuf[X1,Y2] 	; P4 = OrigBuf[X2,Y2]
            Calculate X, Y fractions
            Xfraction = OldX – X1
            Yfraction = OldY – Y1
            Interpolate in X-Direction
            Z1 = P1 × (1 – Xfraction) + P2 × Xfraction
            Z2 = P3 × (1 – Xfraction) + P4 × Xfraction
            Interpolate in Y-Direction
            NewPixel = Z1 × (1 – Yfraction) + Z2 × Yfraction
         */
        public Color calculate(bufferedLockBitmap _original_buffer, float _old_x, float _old_y,int _new_width, int _new_height)
        {
            int new_red, new_green, new_blue;
            Color ret;
            int x_1 = (int)Math.Floor(_old_x);
            int x_2 = x_1 + 1;

            int y_1 = (int)Math.Floor(_old_y);
            int y_2 = y_1 + 1;

            Color p_1 = Color.FromArgb(0);
            Color p_2 = Color.FromArgb(0);
            Color p_3 = Color.FromArgb(0);
            Color p_4 = Color.FromArgb(0);
            if (x_2 < _new_width && y_2 < _new_height)
            {
                p_1 = _original_buffer.Getpixel(x_1, y_1);
                p_2 = _original_buffer.Getpixel(x_2, y_2);
                p_3 = _original_buffer.Getpixel(x_1, y_2);
                p_4 = _original_buffer.Getpixel(x_2, y_2);

            }

            float x_fraction = _old_x - x_1;
            float y_fraction = _old_y - y_1;

            // Interpolate in X-Direction
            // Red
            int r_1 = (int)Math.Floor(p_1.R * (1 - x_fraction) + p_2.R * x_fraction);
            int r_2 = (int)Math.Floor(p_3.R * (1 - x_fraction) + p_4.R * x_fraction);

            // Green
            int g_1 = (int)Math.Floor(p_1.G * (1 - x_fraction) + p_2.G * x_fraction);
            int g_2 = (int)Math.Floor(p_3.G * (1 - x_fraction) + p_4.G * x_fraction);

            // Blue
            int b_1 = (int)Math.Floor(p_1.B * (1 - x_fraction) + p_2.B * x_fraction);
            int b_2 = (int)Math.Floor(p_3.B * (1 - x_fraction) + p_4.B * x_fraction);

            // Interpolate in Y-Direction
            new_red = (int)Math.Floor(r_1 * (1 - y_fraction) + r_2 * y_fraction);
            new_green = (int)Math.Floor(g_1 * (1 - y_fraction) + g_2 * y_fraction);
            new_blue = (int)Math.Floor(b_1 * (1 - y_fraction) + b_2 * y_fraction);
            ret = Color.FromArgb(new_red, new_green, new_blue);
            return ret;
        }
Esempio n. 6
0
 private void comboBox3_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (comboBox3.SelectedValue == (object)"S")
     {
         returned_image = new bufferedLockBitmap(image[comboBox1.SelectedIndex].subtraction(image[comboBox2.SelectedIndex].ImageLockBitmap));
         pictureBox3.Image = returned_image.source;
     }
     else if (comboBox3.SelectedValue == (object)"A")
     {
         if (!string.IsNullOrEmpty(textBox1.Text))
         {
             returned_image = new bufferedLockBitmap(image[comboBox1.SelectedIndex].addtion(image[comboBox2.SelectedIndex].ImageLockBitmap, Convert.ToDouble(textBox1.Text)));
             pictureBox3.Image = returned_image.source;
         }
         else
             MessageBox.Show("please Enter Addition Fraction");
     }
 }
        public Pixel_logic__Operations(bufferedLockBitmap input)
        {
            int te = 0;

            for (int i = 0; i < input.Height; i++)
            {
                for (int j = 0; j < input.Width; j++)
                {
                    te = input.Getpixel(j, i).R;
                    if (te > maxR) maxR = te;

                    te = input.Getpixel(j, i).G;
                    if (te > maxG) maxG = te;

                    te = input.Getpixel(j, i).B;
                    if (te > maxb) maxb = te;

                    te = input.Getpixel(j, i).R;
                    if (te < minR) minR = te;

                    te = input.Getpixel(j, i).G;
                    if (te < minG) minG = te;

                    te = input.Getpixel(j, i).B;
                    if (te < minb) minb = te;

                }
            }
            Word = new byte[8];
            Word[0] = 1;
            Word[1] = 2;
            Word[2] = 4;
            Word[3] = 8;
            Word[4] = 16;
            Word[5] = 32;
            Word[6] = 64;
            Word[7] = 128;
        }
        /**
        For each pixel location in the new buffer P' (NewX, NewY), do:
            Find corresponding old location, P = W-1.P'
            Validate that this old location lie inside the original image boundary (i.e. 0 ≤ OldX < W,  0  ≤ Old Y < H). Otherwise, set the new empty pixel to 0 and continue to next location.
            If Validated, apply Bilinear Interpolation Algorithm to get the new pixel value, as follows:(Refer to above figure)
                */
        public bufferedLockBitmap apply_transformation_matrix_to_bitmap_or_buffer(Matrix _transformations_matrix, bufferedLockBitmap _src_img, int _new_width, int _new_height)
        {
            Bitmap temp = new Bitmap(_new_width, _new_height);
            bufferedLockBitmap ret = new bufferedLockBitmap(temp);
            ret.LockBits();
            BilinearInterpolation obj_bi_lin_interpol = new BilinearInterpolation();
            for (int i = 0; i < _new_width; i++)
            {
                for (int j = 0; j < _new_height; j++)
                {
                    PointF[] points = {
                                          new PointF(i, j)
                                      };
                    _transformations_matrix.TransformPoints(points);

                    Color _color = Color.FromArgb(0);
                    if (points[0].X >= 0 && points[0].X < _src_img.source.Width && points[0].Y >= 0 && points[0].Y < _src_img.source.Height)
                        _color = obj_bi_lin_interpol.calculate(_src_img, points[0].X, points[0].Y, _new_width, _new_height);
                    ret.SetPixel(i, j, _color);
                }
            }
            ret.UnlockBits();
            return ret;
        }
Esempio n. 9
0
 public Bitmap subtraction(bufferedLockBitmap input1)
 {
     return op.Subtraction(input1, this.ImageLockBitmap);
 }
Esempio n. 10
0
        public Bitmap Read(String path)
        {
            String[] pa = path.Split('.');
            if (pa[pa.Length - 1] == "ppm" || pa[pa.Length - 1] == "PPM")
            {
                PP36File = new PP36FileReading(path);
                ImageBitmap = PP36File.ImageBitmap;
                ImageHigh = ImageBitmap.Height;
                ImageWidth = ImageBitmap.Width;
            }
            else
            {
                PP36File = new PP36FileReading();
                PP36File.readbitmap(path);
                ImageBitmap = PP36File.ImageBitmap;
                ImageHigh = ImageBitmap.Height;
                ImageWidth = ImageBitmap.Width;
            }

            ImageLockBitmap = new bufferedLockBitmap(ImageBitmap);
            ImageLockBitmap.LockBits();
            op = new Pixel_logic__Operations(this.ImageLockBitmap);
            return ImageLockBitmap.source;
        }
Esempio n. 11
0
 public bufferedLockBitmap meanfilter(int w, int h, int x, int y)
 {
     this.ImageLockBitmap = NO.LinearFilter(this.ImageLockBitmap, gn.Generatingmean(w, h), w, h, x, y, "NO");
     return this.ImageLockBitmap;
 }
Esempio n. 12
0
 private void numericUpDown2_ValueChanged(object sender, EventArgs e)
 {
     picbox = (PictureBox)tabControl1.TabPages[tabControl1.SelectedIndex].Controls[0];
     bf = image[tabControl1.SelectedIndex].Gamma(dif);
     his = new Histogramdrawing();
     his.drawing(bf, chart1);
     picbox = (PictureBox)tabControl1.TabPages[tabControl1.SelectedIndex].Controls[0];
     picbox.Image = bf.source;
 }
 public bufferedLockBitmap Grayscale(bufferedLockBitmap input)
 {
     input.LockBits();
     int sum = 0;
     for (int i = 0; i < input.Height; i++)
     {
         for (int j = 0; j < input.Width; j++)
         {
             sum = 0;
             sum = input.Getpixel(j, i).R + input.Getpixel(j, i).G + input.Getpixel(j, i).B;
             sum /= 3;
             input.SetPixel(j, i, Color.FromArgb(sum, sum, sum));
         }
     }
     input.UnlockBits();
     return input;
 }
Esempio n. 14
0
 public bufferedLockBitmap Flipping()
 {
     this.ImageLockBitmap = op.FlippingHorizontal(this.ImageLockBitmap);
     return this.ImageLockBitmap;
 }
Esempio n. 15
0
 public bufferedLockBitmap Brightness(int dif)
 {
     this.ImageLockBitmap = op.Brightness(this.ImageLockBitmap, dif);
     return this.ImageLockBitmap;
 }
Esempio n. 16
0
 public bufferedLockBitmap Gamma(double dif)
 {
     this.ImageLockBitmap = op.Gamma(this.ImageLockBitmap, dif);
     return this.ImageLockBitmap;
 }
        /**
        You can use this matrix as follows:
            1 - Create new object with identity matrix (empty constructor)
            2 - Apply a set of transformations that you want to this matrix
            3 - Transform the four corners of the original image to calculate
            4 - The min X and min Y of the transformed image
            5 - The width & height of the new image buffer
            6 - Translate this matrix by (- min X, - min Y)
            7 - Invert the matrix
            8 - Use the inverted version to reverse transform all new locations in the new image buffer
        **/
        public Bitmap perform_concat_matrices_operations(bufferedLockBitmap _src_img, float _shear_x = (float)0, float _shear_y = (float)0, float _scale_x = (float)1, float _scale_y = (float)1, float _rotate_theta = (float)0)
        {
            bufferedLockBitmap ret;

            // 1 - Create new object with identity matrix (empty constructor)
            Matrix transformations_matrix = new Matrix();
            // 2 - Apply a set of transformations that you want to this matrix
            transformations_matrix.Rotate(_rotate_theta, MatrixOrder.Append);
            transformations_matrix.Scale(_scale_x, _scale_y, MatrixOrder.Append);
            transformations_matrix.Shear(_shear_x, _shear_y, MatrixOrder.Append);
            // 3 - Transform the four corners of the original image to calculate
            /**
             * To get the size of the new (destination) image,
             * apply the forward mapping to the four corners of the original image
             * ([0,0], [W-1,0], [0,H-1], [W-1,H-1])
             * to get their new locations.
             * Then use these new four locations to get the width and height of the destination image
             * (e.g. to get new width:
             * find min X & max X of the four new points and subtract them,
             * do the same for Y to get the new height)
             */
            Point[] corner_points = {
                                        new Point(0, 0),
                                        new Point(_src_img.source.Width - 1, 0),
                                        new Point(0, _src_img.source.Height - 1),
                                        new Point(_src_img.source.Width - 1, _src_img.source.Height - 1)
                                    };

            transformations_matrix.TransformPoints(corner_points);

            int min_x = find_min_x(corner_points);
            int min_y = find_min_y(corner_points);

            int max_x = find_max_x(corner_points);
            int max_y = find_max_y(corner_points);

            int new_width =Math.Abs(Math.Abs(max_x) - Math.Abs(min_x));//edited
            int new_height = Math.Abs(max_y) - Math.Abs(min_y);//edited

            // 4 - The min X and min Y of the transformed image
            /**
             * To make the transformed image totally fit inside the buffer, a translation with (- min X, - min Y) should be appended to the original transformation matrix (W) before inverting it.
             */

            // 6 - Translate this matrix by (- min X, - min Y)
            transformations_matrix.Translate(-min_x, -min_y, MatrixOrder.Append);

            // 7 - Invert the matrix
            transformations_matrix.Invert();

            // 8 - Use the inverted version to reverse transform all new locations in the new image buffer
            return apply_transformation_matrix_to_bitmap_or_buffer(transformations_matrix, _src_img, new_width, new_height).source;
        }
 public void Quantization(bufferedLockBitmap input, int num)
 {
     int sum = 0;
     double f = 2;
     int math = Convert.ToInt32(Math.Log(Convert.ToDouble(num), f));
     for (int w = 7; w > 7 - math; w--)
     {
         sum = sum + Convert.ToInt32(Math.Pow(f, Convert.ToInt32(w)));
     }
     temp = new Bitmap(input.Width, input.Height);
     bf = new bufferedLockBitmap(temp);
     input.LockBits();
     int R, G, B;
     for (int i = 0; i < input.Height; i++)
     {
         for (int j = 0; j < input.Width; j++)
         {
             R = input.Getpixel(j, i).R & sum;
             G = input.Getpixel(j, i).G & sum;
             B = input.Getpixel(j, i).B & sum;
             input.SetPixel(j, i, Color.FromArgb(R, G, B));
         }
     }
     input.UnlockBits();
 }
        public Bitmap Subtraction(bufferedLockBitmap pic1, bufferedLockBitmap pic2)
        {
            temp = new Bitmap(pic1.Width, pic1.Height);
            bufferedLockBitmap bf = new bufferedLockBitmap(temp);
            bf.LockBits();
            int gmaxR = 0, gmaxG = 0, gmaxb = 0, gminR = 1000, gminG = 10000, gminb = 1000;
            int te;

            int R, G, B = 0;
            if (pic1.Width == pic2.Width)
            {
                R = 0; G = 0; B = 0;
                for (int i = 0; i < pic1.Height; i++)
                {
                    for (int j = 0; j < pic1.Width; j++)
                    {
                        R = Math.Abs(pic1.Getpixel(j, i).R - pic2.Getpixel(j, i).R);
                        G = Math.Abs(pic1.Getpixel(j, i).G - pic2.Getpixel(j, i).G);
                        B = Math.Abs(pic1.Getpixel(j, i).B - pic2.Getpixel(j, i).B);
                        te = R;
                        if (te > gmaxR) gmaxR = te;
                        if (te < gminR) gminR = te;

                        te = G;

                        if (te > gmaxb) gmaxb = te;
                        if (te < gminb) gminb = te;
                        te = B;
                        if (te > gmaxG) gmaxG = te;
                        if (te < gminG) gminG = te;

                    }
                }
            }

            for (int i = 0; i < pic1.Height; i++)
            {
                for (int j = 0; j < pic1.Width; j++)
                {

                    R = Math.Abs(pic1.Getpixel(j, i).R - pic2.Getpixel(j, i).R);
                    G = Math.Abs(pic1.Getpixel(j, i).G - pic2.Getpixel(j, i).G);
                    B = Math.Abs(pic1.Getpixel(j, i).B - pic2.Getpixel(j, i).B);
                    R = Convert.ToInt32(((double)(R - minR) / (maxR - minR)) * ((255 - 0)));
                    G = Convert.ToInt32(((double)(G - minG) / (maxG - minG)) * ((255 - 0)));
                    B = Convert.ToInt32(((double)(B - minb) / (maxb - minb)) * ((255 - 0)));
                    if (R > 255) R = 255;
                    else if (R < 0) R = 0;
                    if (G > 255) G = 255;
                    else if (G < 0) G = 0;
                    if (B > 255) B = 255;
                    else if (B < 0) B = 0;
                    bf.SetPixel(j, i, Color.FromArgb(Convert.ToInt32(R), Convert.ToInt32(G), Convert.ToInt32(B)));
                }
            }

            bf.UnlockBits();
            return bf.source;
        }
Esempio n. 20
0
 private void trackBar2_Scroll(object sender, EventArgs e)
 {
     bf = image[tabControl1.SelectedIndex].Gamma(dif);
     his = new Histogramdrawing();
     his.drawing(bf, chart1);
     picbox = (PictureBox)tabControl1.TabPages[tabControl1.SelectedIndex].Controls[0];
     picbox.Image = image[tabControl1.SelectedIndex].Gamma(dif).source;
 }
Esempio n. 21
0
 public Bitmap addtion(bufferedLockBitmap input1, double diff)
 {
     return op.Addpictures(input1, this.ImageLockBitmap, diff);
 }
        public bufferedLockBitmap Gamma(bufferedLockBitmap input, double dif)
        {
            if (dif == 0)
                return input;
            if (dif < 0)
                dif = 1 / Math.Abs(dif);
            double te = 0;
            double gmaxR = -10000, gmaxG =-10000, gmaxb = -10000, gminR = 10000, gminG = 10000, gminb = 10000;
            for (int i = 0; i < input.Height; i++)
            {
                for (int j = 0; j < input.Width; j++)
                {
                    te = Math.Pow(input.Getpixel(j, i).R, dif);
                    if (te > gmaxR) gmaxR = te;
                    else if (te < gminR) gminR = te;

                    te = Math.Pow(input.Getpixel(j, i).B, dif);
                    if (te > gmaxb) gmaxb = te;
                    else if (te < gminb) gminb = te;

                    te = Math.Pow(input.Getpixel(j, i).G, dif);
                    if (te > gmaxG) gmaxG = te;
                     if (te < gminG) gminG = te;

                }
            }

            temp = new Bitmap(input.Width, input.Height);
            bf = new bufferedLockBitmap(temp);
            bf.LockBits();
            double R, G, B = 0,x;
            for (int i = 0; i < input.Height; i++)
            {
                for (int j = 0; j < input.Width; j++)
                {
                    R = (Math.Pow(input.Getpixel(j, i).R, dif));
                    x = (Math.Pow(input.Getpixel(j, i).G, dif));
                    B = (Math.Pow(input.Getpixel(j, i).B, dif));

                    R = Convert.ToInt32(((double)(R - gminR) / (gmaxR - gminR)) * (255 - 0));
                    G = Convert.ToInt32(((double)(x - gminG) / (gmaxG - gminG)) * (255 - 0));
                    B = Convert.ToInt32(((double)(B - gminb) / (gmaxb - gminb)) * (255 - 0));

                    //if (R > 255) R = 255;
                    //else if (R < 0) R = 0;
                    //if (G > 255) G = 255;
                    //else if (G < 0) G = 0;
                    //if (B > 255) B = 255;
                    //else if (B < 0) B = 0;
                    bf.SetPixel(j, i, Color.FromArgb(Convert.ToInt32(R), Convert.ToInt32(G), Convert.ToInt32(B)));
                }
            }
            bf.UnlockBits();
            return bf;
        }
Esempio n. 23
0
 public bufferedLockBitmap Bit_plane_slicing(int x, bool R, bool G, bool B)
 {
     this.ImageLockBitmap = op.Bit_plane(this.ImageLockBitmap, x, R, G, B);
     return this.ImageLockBitmap;
 }
Esempio n. 24
0
        public Bitmap laplacian()
        {
            this.ImageLockBitmap = NO.LinearFilter(this.ImageLockBitmap, gn.lap(), 3, 3, 0, 0, "cutoff");

            return this.ImageLockBitmap.source;
        }
        public void notoperation(bufferedLockBitmap input, int dif)
        {
            if (dif == 0)
                for (int i = 0; i < input.Height; i++)
                {
                    for (int j = 0; j < input.Width; j++)
                    {
                        input.SetPixel(j, i, Color.FromArgb(dif - input.Getpixel(j, i).R, dif - input.Getpixel(j, i).G, dif - input.Getpixel(j, i).B));
                    }
                }
            else
            {
                temp = new Bitmap(input.Width, input.Height);
                bufferedLockBitmap bf = new bufferedLockBitmap(temp);
                bf.LockBits();
                int gmaxR = 0, gmaxG = 0, gmaxb = 0, gminR = 1000, gminG = 10000, gminb = 1000;
                int te;

                int R, G, B = 0;
                for (int i = 0; i < input.Height; i++)
                {
                    for (int j = 0; j < input.Width; j++)
                    {
                        R = dif - input.Getpixel(j, i).R;
                        G = dif - input.Getpixel(j, i).G;
                        B = dif - input.Getpixel(j, i).B;
                        te = R;
                        if (te > gmaxR) gmaxR = te;
                        if (te < gminR) gminR = te;

                        te = G;

                        if (te > gmaxb) gmaxb = te;
                        if (te < gminb) gminb = te;
                        te = B;
                        if (te > gmaxG) gmaxG = te;
                        if (te < gminG) gminG = te;

                    }
                }

                for (int i = 0; i < input.Height; i++)
                {
                    for (int j = 0; j < input.Width; j++)
                    {
                        R =Math.Abs( dif - input.Getpixel(j, i).R);
                        G = Math.Abs(dif - input.Getpixel(j, i).G);
                        B = Math.Abs(dif - input.Getpixel(j, i).B);

                        //R = Convert.ToInt32(((double)(R - minR) / (maxR - minR)) * ((255 - 0)));
                        //G = Convert.ToInt32(((double)(G - minG) / (maxG - minG)) * ((255 - 0)));
                        //B = Convert.ToInt32(((double)(B - minb) / (maxb - minb)) * ((255 - 0)));

                        if (R > 255) R = 255;
                        else if (R < 0) R = 0;
                        if (G > 255) G = 255;
                        else if (G < 0) G = 0;
                        if (B > 255) B = 255;
                        else if (B < 0) B = 0;
                        input.SetPixel(j, i, Color.FromArgb(Convert.ToInt32(R), Convert.ToInt32(G), Convert.ToInt32(B)));
                    }

                }
                bf.UnlockBits();
            }
        }
Esempio n. 26
0
 public bufferedLockBitmap line_detectionv()
 {
     this.ImageLockBitmap = NO.LinearFilter(this.ImageLockBitmap, gn.line_detect_vertical(), 3, 3, 1, 1, "abs");
     return this.ImageLockBitmap;
 }
Esempio n. 27
0
 public Bitmap Flippingvertical()
 {
     this.ImageLockBitmap = op.Flippingvertical(this.ImageLockBitmap);
     return this.ImageLockBitmap.source;
 }
Esempio n. 28
0
 public bufferedLockBitmap mean1D(int masksize)
 {
     this.ImageLockBitmap = NO.LinearFilter(this.ImageLockBitmap, gn.Generatingmean(1, masksize), 1, masksize, 0, 0, "NO");
     return this.ImageLockBitmap;
 }
Esempio n. 29
0
 public Bitmap Grayscale()
 {
     this.ImageLockBitmap = op.Grayscale(this.ImageLockBitmap);
     return this.ImageLockBitmap.source;
 }
        public Bitmap AND(bufferedLockBitmap pic1, bufferedLockBitmap pic2)
        {
            temp = new Bitmap(pic1.Width, pic1.Height);
            bufferedLockBitmap bf = new bufferedLockBitmap(temp);
            bf.LockBits();
            int R, G, B = 0;
            if (pic1.Width == pic2.Width)
            {
                R = 0; G = 0; B = 0;
                for (int i = 0; i < pic1.Height; i++)
                {
                    for (int j = 0; j < pic1.Width; j++)
                    {
                        R = pic1.Getpixel(j, i).R & pic2.Getpixel(j, i).R;
                        G = pic1.Getpixel(j, i).G & pic2.Getpixel(j, i).G;
                        B = pic1.Getpixel(j, i).B & pic2.Getpixel(j, i).B;

                        bf.SetPixel(j, i, Color.FromArgb(Convert.ToInt32(R), Convert.ToInt32(G), Convert.ToInt32(B)));

                    }
                }
            }
            bf.UnlockBits();
            return bf.source;
        }