Example #1
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            //If autoProcessCheckBox is not checked the rest of the method will not run
            if (!autoProcessCheckBox.Checked)
            {
                return;
            }

            //Grabs new frame from videosource and modifies the gama and contrast based on sliders
            processImage();
            //Sets capturedImagePanel to the modified snapshot
            capturedImagePanel.Image = workingImage;
            //Apply canny edge detector
            cannyImageConvert();
            //Rotate the image based on the degree offset returned by findDegreeTilt
            RotateNearestNeighbor rotateFilter = new RotateNearestNeighbor(findDegreeTilt(workingImage), false);

            rotateFilter.FillColor = (Color.Black);
            workingImage           = rotateFilter.Apply(workingImage);
            //Centers the part with the centerPart method
            workingImage = centerPart(workingImage);
            //Updates correctedImagePanel with rotated and centered image
            correctedImagePanel.Image = workingImage;
            //Updates the size of the part and the proper orientation
            scaleFactorUpdate();
        }
Example #2
0
        private void GeneratedImage()
        {
            labelDegree.Text   = string.Format("{0}'", Grigore.Direction);
            labelPosition.Text = string.Format("{0}, {1}", Grigore.Position.X, Grigore.Position.Y);

            Bitmap orig;

            try {
                orig = (Bitmap)Bitmap.FromFile(OriginalBoardImage);
            }
            catch
            {
                // kill any exception due to missing files
                return;
            }

            Bitmap rotatedRobot = AForge.Imaging.Image.Clone(Grigore.Image, System.Drawing.Imaging.PixelFormat.Format24bppRgb);

            Graphics g = Graphics.FromImage(orig);

            BaseRotateFilter filter = new RotateNearestNeighbor(Grigore.Direction, false);

            filter.FillColor = Color.Transparent;
            rotatedRobot     = filter.Apply(rotatedRobot);

            g.DrawImage(rotatedRobot, Grigore.Position);

            g.Dispose();

            pictureBoxGenerated.Image = orig;
        }
Example #3
0
        private void CameraOne_NewFrame(object sender, NewFrameEventArgs eventArgs)
        {
            Bitmap    bitmap1 = (Bitmap)(eventArgs.Frame.DeepClone());
            Grayscale filter  = new Grayscale(0.2, 0.7, 0.07);

            if (checkBox1.Checked)
            {
                bitmap1 = filter.Apply(bitmap1);
            }
            int x = 0;

            Invoke(new MethodInvoker(delegate
            {
                x = trackBar1.Value;
            }));
            RotateNearestNeighbor filterrot = new RotateNearestNeighbor(x, true);

            bitmap1 = filterrot.Apply(bitmap1);
            ResizeBicubic filterResizeBicubic = new ResizeBicubic(320, 240);

            bitmap1 = filterResizeBicubic.Apply(bitmap1);
            if (button1WasClicked)
            {
                Convolution conv = new Convolution(new[, ]
                {
                    { int.Parse(textBox1.Text), int.Parse(textBox2.Text), int.Parse(textBox3.Text) },
                    { int.Parse(textBox4.Text), int.Parse(textBox5.Text), int.Parse(textBox6.Text) },
                    { int.Parse(textBox7.Text), int.Parse(textBox8.Text), int.Parse(textBox9.Text) }
                });
                bitmap1 = conv.Apply(bitmap1);
            }
            pictureBox1.Image = bitmap1;
        }
Example #4
0
        private void GeneratedImage()
        {
            Console.WriteLine(string.Format("Start generating\nAngle: {0}'", Grigore.Direction));
            Console.WriteLine(string.Format("Position (x, y): {0}, {1}", Grigore.Position.X, Grigore.Position.Y));

            Bitmap orig;

            try
            {
                orig = (Bitmap)Bitmap.FromFile(OriginalBoardImage);
            }
            catch
            {
                // kill any exception due to missing files
                return;
            }

            Bitmap rotatedRobot = AForge.Imaging.Image.Clone(Grigore.Image, System.Drawing.Imaging.PixelFormat.Format24bppRgb);

            Graphics g = Graphics.FromImage(orig);

            BaseRotateFilter filter = new RotateNearestNeighbor(Grigore.Direction, false);

            filter.FillColor = Color.Transparent;
            rotatedRobot     = filter.Apply(rotatedRobot);

            g.DrawImage(rotatedRobot, Grigore.Position);

            g.Dispose();

            internalImageContainer = orig;

            orig.Save(dirPath + "processed-generated.jpg");
        }
Example #5
0
        public mRotateNearistNeighbor(double Angle, bool Fit, System.Drawing.Color CornerColor)
        {
            BitmapType = mFilter.BitmapTypes.Rgb24bpp;

            Effect           = new RotateNearestNeighbor(Angle, Fit);
            Effect.FillColor = CornerColor;

            filter = Effect;
        }
Example #6
0
        private void rotateBtn_Click(object sender, EventArgs e)
        {
            //Rotates Image based on the findDegreeTilt method(the method returns the degree of tilt)
            //IMPORTANT: Always rotate and then center
            RotateNearestNeighbor rotateFilter = new RotateNearestNeighbor(findDegreeTilt(workingImage), false);

            rotateFilter.FillColor    = (Color.Black);
            workingImage              = rotateFilter.Apply(workingImage);
            correctedImagePanel.Image = workingImage;
        }
Example #7
0
        void goruntuGuncelle()
        {
            try
            {
                if (comboBox1.SelectedIndex == 0)
                {
                    //resim döndürme filtresi tanımlandı
                    //bu filtre sistemi yormuyor
                    //diğerleri sistemi zorluyor
                    //resim döndürme saat yönünün tersine doğru yapılıyor

                    //fonksiyona paremetre olarak true verilirse resmin tamamı ekrana sığdırılmıyor
                    //bazı yerler kırpılıyor
                    //fakat resim boyutu (genişliği ve yükseliği) değişmiyor
                    //görüntü daha güzel görünüyor

                    //eğer false olursa resim küçültme büyütme işlemelerinde resim boyutuda (genişliği ve yükseliği) değişiyor
                    //yani false olunca resim daima ekrana sığdırılıyor
                    RotateNearestNeighbor boyutlandirmaFiltresi = new RotateNearestNeighbor(trackBar1.Value, tamEkran);
                    //resim dosyasına filtre uygulandı
                    pictureBox2.Image = boyutlandirmaFiltresi.Apply((Bitmap)pictureBox1.Image);
                    //resim boyut değiştirme filtresi tanımlandı
                    //bu filtre sistemi yormuyor
                    //diğerleri sistemi zorluyor
                    ResizeNearestNeighbor boyutlandirma = new ResizeNearestNeighbor(resim.Width + trackBar2.Value, resim.Height + trackBar2.Value);
                    //resim dosyasına filtre uygulandı
                    pictureBox2.Image = boyutlandirma.Apply((Bitmap)pictureBox1.Image);
                }
                if (comboBox1.SelectedIndex == 1)
                {
                    //resim döndürme filtresi tanımlandı
                    RotateBilinear boyutlandirmaFiltresi = new RotateBilinear(trackBar1.Value, tamEkran);
                    //resim dosyasına filtre uygulandı
                    pictureBox2.Image = boyutlandirmaFiltresi.Apply((Bitmap)pictureBox1.Image);
                    //resim boyut değiştirme filtresi tanımlandı
                    ResizeBicubic boyutlandirma = new ResizeBicubic(resim.Width + trackBar2.Value, resim.Height + trackBar2.Value);
                    //resim dosyasına filtre uygulandı
                    pictureBox2.Image = boyutlandirma.Apply((Bitmap)pictureBox1.Image);
                }
                if (comboBox1.SelectedIndex == 2)
                {
                    //resim döndürme filtresi tanımlandı
                    RotateBicubic boyutlandirmaFiltresi = new RotateBicubic(trackBar1.Value, tamEkran);
                    //resim dosyasına filtre uygulandı
                    pictureBox2.Image = boyutlandirmaFiltresi.Apply((Bitmap)pictureBox1.Image);
                    //resim boyut değiştirme filtresi tanımlandı
                    ResizeBilinear boyutlandirma = new ResizeBilinear(resim.Width + trackBar2.Value, resim.Height + trackBar2.Value);
                    //resim dosyasına filtre uygulandı
                    pictureBox2.Image = boyutlandirma.Apply((Bitmap)pictureBox1.Image);
                }
            }
            catch
            {
            }
        }
Example #8
0
        private void button7_Click(object sender, EventArgs e)
        {
            string path        = OriPath + "\\test.jpg";
            string pathoutput2 = OriPath + "\\testoutput2.jpg";
            string pathoutput3 = OriPath + "\\testoutput3.jpg";
            string pathoutput4 = OriPath + "\\testoutput4.jpg";
            string pathoutput5 = OriPath + "\\testoutput5.jpg";
            string pathoutput6 = OriPath + "\\testoutput6.jpg";
            string pathoutput7 = OriPath + "\\testoutput7.jpg";


            Bitmap image = new Bitmap(path);

            // 普通最近领算法
            ResizeNearestNeighbor filter = new ResizeNearestNeighbor(4000, 3000);
            // 双线性插值
            ResizeBicubic filter2 = new ResizeBicubic(4000, 3000);
            // 双三次插值
            ResizeBilinear filter3 = new ResizeBilinear(4000, 3000);

            // create filter - rotate for 30 degrees keeping original image size
            RotateNearestNeighbor filter4 = new RotateNearestNeighbor(30, true);

            RotateBilinear filter5 = new RotateBilinear(30, true);

            RotateBicubic filter6 = new RotateBicubic(30, true);

            // apply the filter
            Bitmap newImage = filter.Apply(image);

            newImage.Save(pathoutput2);

            newImage = filter2.Apply(image);
            newImage.Save(pathoutput3);

            newImage = filter3.Apply(image);
            newImage.Save(pathoutput4);

            newImage = filter4.Apply(image);
            newImage.Save(pathoutput5);

            newImage = filter5.Apply(image);
            newImage.Save(pathoutput6);

            newImage = filter6.Apply(image);
            newImage.Save(pathoutput7);
        }