Exemplo n.º 1
0
        private void histogramToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (img == null) // verify if the image is already opened
            {
                return;
            }
            Cursor = Cursors.WaitCursor; // clock cursor

            //copy Undo Image
            imgUndo = img.Copy();

            int[] histogram1 = new int[255];
            histogram1[150] = 2000;
            histogram1[151] = 2000;
            histogram1[152] = 2000;
            int[]     histogram  = ImageClass.Histogram_Gray(img);
            Histogram histoChart = new Histogram("Gray Histogram", histogram, histogram1);

            //histoChart.chart1.Series[0].Points.DataBindY
            //            (histogram);
            //histoChart.chart1.Series[0].Points.DataBindY
            //            (histogram1);
            histoChart.ShowDialog();
            ImageViewer.Image = img.Bitmap;
            ImageViewer.Refresh();    // refresh image on the screen

            Cursor = Cursors.Default; // normal cursor
        }
Exemplo n.º 2
0
        private void rotationBilinearToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (img == null) // verify if the image is already opened
            {
                return;
            }
            Cursor = Cursors.WaitCursor; // clock cursor
            float angleRad = 0;

            //copy Undo Image
            imgUndo = img.Copy();

            InputBox form = new InputBox("Qual o valor do ângulo a rodar?");

            form.ShowDialog();
            int angle = Convert.ToInt32(form.ValueTextBox.Text);

            angleRad = (float)(Math.PI / 180) * angle;

            ImageClass.Rotation_Bilinear(img, imgUndo, angleRad);

            ImageViewer.Image = img.Bitmap;
            ImageViewer.Refresh();    // refresh image on the screen

            Cursor = Cursors.Default; // normal cursor
        }
Exemplo n.º 3
0
        private void ScalePointToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (img == null) // verify if the image is already opened
            {
                return;
            }
            Cursor = Cursors.WaitCursor; // clock cursor

            //input boxes
            InputBox form = new InputBox("scale?");

            form.ShowDialog();
            float scaleFactor = Convert.ToInt32(form.ValueTextBox.Text);

            InputBox formx = new InputBox("x?");

            formx.ShowDialog();
            int centerX = Convert.ToInt32(formx.ValueTextBox.Text);

            InputBox formy = new InputBox("y?");

            formy.ShowDialog();
            int centerY = Convert.ToInt32(formy.ValueTextBox.Text);

            //copy Undo Image
            imgUndo = img.Copy();

            ImageClass.Scale_point_xy(img, imgUndo, scaleFactor, centerX, centerY);

            ImageViewer.Image = img.Bitmap;
            ImageViewer.Refresh();    // refresh image on the screen

            Cursor = Cursors.Default; // normal cursor
        }
Exemplo n.º 4
0
        private void brightnessToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            if (img == null) // verify if the image is already opened
            {
                return;
            }
            Cursor = Cursors.WaitCursor; // clock cursor

            //copy Undo Image
            imgUndo = img.Copy();

            InputBox form = new InputBox("brilho?");

            form.ShowDialog();
            int brilho = Convert.ToInt32(form.ValueTextBox.Text);
            // form2.ResetText();


            InputBox form2 = new InputBox("Contraste?");

            form2.ShowDialog();
            double cont = Convert.ToDouble(form.ValueTextBox.Text);


            ImageClass.BrightContrast(img, brilho, cont);


            ImageViewer.Image = img.Bitmap;
            ImageViewer.Refresh();    // refresh image on the screen

            Cursor = Cursors.Default; // normal cursor
        }
Exemplo n.º 5
0
        private void binarizaçãoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (img == null) // verify if the image is already opened
            {
                return;
            }


            //copy Undo Image
            imgUndo = img.Copy();
            Cursor  = Cursors.WaitCursor; // clock cursor

            InputBox form = new InputBox("Qual o valor de Threshold?");

            form.ShowDialog();
            //float scaleFactor = (float)Convert.ToDecimal(form.ValueTextBox.Text);
            int threshold = int.Parse(form.ValueTextBox.Text);



            //apply the zoom
            ImageClass.ConvertToBW(img, threshold);


            ImageViewer.Image = img.Bitmap;
            ImageViewer.Refresh();    // refresh image on the screen

            Cursor = Cursors.Default; // normal cursor
        }
Exemplo n.º 6
0
        private void medianaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (img == null) // verify if the image is already opened
            {
                return;
            }


            Cursor = Cursors.WaitCursor; // clock cursor

            //copy Undo Image
            imgUndo = img.Copy();


            try
            {
                ImageClass.Median(img, imgUndo);
            }
            catch { }

            ImageViewer.Image = img.Bitmap;
            ImageViewer.Refresh();    // refresh image on the screen

            Cursor = Cursors.Default; // normal cursor
        }
Exemplo n.º 7
0
        public PuzzleForm(Image <Bgr, Byte> img)
        {
            InitializeComponent();
            pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
            Cursor = Cursors.WaitCursor;             // clock cursor

            rotatedImg  = img.Copy();
            originalImg = img.Copy();
            ImageClass.puzzleRotateOnly(rotatedImg, rotatedImg.Copy());


            finishedImg = ImageClass.puzzle(img, img.Copy(), out pieces, out pieces_angles, 3);

            paintBlack(rotatedImg, pieces);
            paintBlack(originalImg, pieces);
            Cursor = Cursors.Default;             // normal cursor

            for (int i = 0; i < pieces.Count; i++)
            {
                ListViewItem lvi = new ListViewItem(i.ToString());
                lvi.SubItems.Add(pieces_angles[i].ToString() + " Degrees");
                listView1.Items.Add(lvi);
            }
            listView1.Refresh();

            pictureBox1.Image = originalImg.Bitmap;
        }
Exemplo n.º 8
0
        private void signsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (img == null)
            {
                return;
            }

            Cursor = Cursors.WaitCursor; // clock cursor

            //copy Undo Image
            imgUndo = img.Copy();
            List <string[]> limitSign       = new List <string[]>();
            List <string[]> warningSign     = new List <string[]>();
            List <string[]> prohibitionSign = new List <string[]>();

            ImageClass.Signs(img, imgUndo, out limitSign, out warningSign, out prohibitionSign, 0);

            ImageViewer.Image = img.Bitmap;
            ImageViewer.Refresh(); // refresh image on the screen
            SignsForm signForm = new SignsForm(limitSign, warningSign, prohibitionSign);

            signForm.ShowDialog();

            Cursor = Cursors.Default; // normal cursor
        }
Exemplo n.º 9
0
        private void translationToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (img == null)
            {
                return;
            }

            Cursor = Cursors.WaitCursor; // clock cursor
            InputBox dxForm = new InputBox("dx?");

            dxForm.ShowDialog();
            int dx = Convert.ToInt32(dxForm.ValueTextBox.Text);

            InputBox dyForm = new InputBox("dy?");

            dxForm.ShowDialog();
            int dy = Convert.ToInt32(dyForm.ValueTextBox.Text);

            //copy Undo Image
            imgUndo = img.Copy();
            ImageClass.Translation(img, imgUndo, dx, dy);

            ImageViewer.Image = img.Bitmap;
            ImageViewer.Refresh();    // refresh image on the screen

            Cursor = Cursors.Default; // normal cursor
        }
Exemplo n.º 10
0
        private void manualToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (img == null)             // verify if the image is already opened
            {
                return;
            }
            Cursor = Cursors.WaitCursor;             // clock cursor

            InputBox form = new InputBox("Input treshold (0-255)");

            form.ShowDialog();
            int threshold = int.Parse(form.ValueTextBox.Text);

            if (threshold < 0)
            {
                threshold = 0;
            }
            else if (threshold > 255)
            {
                threshold = 255;
            }

            //copy Undo Image
            imgUndo = img.Copy();

            ImageClass.ConvertToBW(img, threshold);

            ImageViewer.Image = img.Bitmap;
            ImageViewer.Refresh();             // refresh image on the screen

            Cursor = Cursors.Default;          // normal cursor
        }
Exemplo n.º 11
0
        private void nonUniformToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (img == null) // verify if the image is already opened
            {
                return;
            }
            Cursor = Cursors.WaitCursor; // clock cursor

            WeightForm weightForm = new WeightForm();

            weightForm.ShowDialog();
            bool okay = weightForm.getFormStatus();

            //copy Undo Image
            imgUndo = img.Copy();
            Image <Bgr, Byte> imgCopy = img.Copy();

            if (okay)
            {
                ImageClass.NonUniform(img, imgCopy, weightForm.getMatrix(), weightForm.getMatrixWeight());
            }

            ImageViewer.Image = img.Bitmap;
            ImageViewer.Refresh();    // refresh image on the screen

            Cursor = Cursors.Default; // normal cursor
        }
Exemplo n.º 12
0
        private void zoomToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (img == null)             // verify if the image is already opened
            {
                return;
            }

            using (ScaleForm form = new ScaleForm())
            {
                if (form.ShowDialog() == DialogResult.OK)
                {
                    Cursor = Cursors.WaitCursor;                     // clock cursor
                    //copy Undo Image
                    imgUndo = img.Copy();
                    if (form.useCenter)
                    {
                        ImageClass.Scale_point_xy(img, imgUndo, form.scale, form.xCenter, form.yCenter);
                    }
                    else
                    {
                        ImageClass.Scale(img, imgUndo, form.scale);
                    }

                    ImageViewer.Image = img.Bitmap;
                    ImageViewer.Refresh();                     // refresh image on the screen

                    Cursor = Cursors.Default;                  // normal cursor
                }
            }
        }
Exemplo n.º 13
0
        private void biLinearToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (img == null) // verify if the image is already opened
            {
                return;
            }
            Cursor = Cursors.WaitCursor; // clock cursor

            //copy Undo Image
            imgUndo = img.Copy();

            InputBox formz = new InputBox("Zoom (factor)?");

            formz.ShowDialog();
            string factorZ  = formz.ValueTextBox.Text;
            bool   successc = float.TryParse(factorZ, out float j);

            if (successc && j > 0)
            {
                ImageClass.Scale_Bilinear(img, imgUndo, j);


                ImageViewer.Image = img.Bitmap;
                ImageViewer.Refresh();    // refresh image on the screen

                Cursor = Cursors.Default; // normal cursor
            }
            else
            {
                MessageBox.Show("Value for Zoom must be a number bigger than zero.", "Error",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error); // for Error
            }
        }
Exemplo n.º 14
0
        private void bWToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (img == null) // verify if the image is already opened
            {
                return;
            }
            Cursor = Cursors.WaitCursor; // clock cursor

            //copy Undo Image
            imgUndo = img.Copy();

            InputBox formbw = new InputBox("Threshold?");

            formbw.ShowDialog();
            string threshold = formbw.ValueTextBox.Text;
            bool   success   = int.TryParse(threshold, out int i);

            if (success && i >= 0 && i <= 255)
            {
                ImageClass.ConvertToBW(img, i);

                ImageViewer.Image = img.Bitmap;
                ImageViewer.Refresh();    // refresh image on the screen

                Cursor = Cursors.Default; // normal cursor
            }
            else
            {
                MessageBox.Show("Value must be an integer from 0 to 255.", "Error",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error); // for Error
            }
        }
Exemplo n.º 15
0
        private void bilinearToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (img == null) // verify if the image is already opened
            {
                return;
            }
            Cursor = Cursors.WaitCursor; // clock cursor

            //copy Undo Image
            imgUndo = img.Copy();

            InputBox rot = new InputBox("Rotation Angle", numberTextBox);

            rot.ShowDialog();
            if (rot.DialogResult == DialogResult.OK)
            {
                int   ang = Convert.ToInt32(rot.ValueTextBox.Text);
                float rad = Convert.ToSingle(Math.PI / 180.0 * ang);

                ImageClass.Rotation_Bilinear(img, img.Copy(), rad);

                ImageViewer.Image = img.Bitmap;
                ImageViewer.Refresh(); // refresh image on the screen
            }

            Cursor = Cursors.Default; // normal cursor
        }
Exemplo n.º 16
0
        private void ContrastBrightnessToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (img == null) // verify if the image is already opened
            {
                return;
            }
            Cursor = Cursors.WaitCursor; // clock cursor

            InputBox input = new InputBox("Contrast (0 to 3):");

            input.ShowDialog();
            double contrast_value = Convert.ToDouble(input.ValueTextBox.Text);


            input = new InputBox("Brightness (0 to 255):");
            input.ShowDialog();
            int brightness_value = Convert.ToInt32(input.ValueTextBox.Text);

            //copy Undo Image
            imgUndo = img.Copy();

            ImageClass.BrightContrast(img, brightness_value, contrast_value);

            ImageViewer.Image = img.Bitmap;
            ImageViewer.Refresh();    // refresh image on the screen

            Cursor = Cursors.Default; // normal cursor
        }
Exemplo n.º 17
0
        private void bilinearToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            if (img == null) // verify if the image is already opened
            {
                return;
            }
            Cursor = Cursors.Cross; // cross cursor

            //copy Undo Image
            imgUndo = img.Copy();

            InputBox zoom = new InputBox("Zoom Level", decimalTextBox);

            mouseFlag = true;
            while (mouseFlag)
            {
                Application.DoEvents();
            }

            zoom.ShowDialog();

            float factor = Convert.ToSingle(zoom.ValueTextBox.Text);

            Cursor = Cursors.WaitCursor; // clock cursor

            ImageClass.Scale_point_xy_Bilinear(img, img.Copy(), factor, mouseX, mouseY);

            ImageViewer.Image = img.Bitmap;
            ImageViewer.Refresh();    // refresh image on the screen

            Cursor = Cursors.Default; // normal cursor
        }
Exemplo n.º 18
0
        private void TranslationToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (img == null) // verify if the image is already opened
            {
                return;
            }
            Cursor = Cursors.WaitCursor; // clock cursor

            InputBox input = new InputBox("Dx:");

            input.ShowDialog();
            int trans_x = Convert.ToInt32(input.ValueTextBox.Text);


            input = new InputBox("Dy:");
            input.ShowDialog();
            int trans_y = Convert.ToInt32(input.ValueTextBox.Text);

            //copy Undo Image
            imgUndo = img.Copy();

            Image <Bgr, byte> imgCopy = img.Clone();

            ImageClass.Translation(img, imgCopy, trans_x, trans_y);

            ImageViewer.Image = img.Bitmap;
            ImageViewer.Refresh();    // refresh image on the screen

            Cursor = Cursors.Default; // normal cursor
        }
Exemplo n.º 19
0
        private void plateTestingToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (img == null) // protege de executar a função sem ainda ter aberto a imagem
            {
                return;
            }

            Cursor = Cursors.WaitCursor; // cursor relogio
            //copy Undo Image
            imgUndo  = img.Copy();
            imgPlate = img.Copy();
            //Image<Bgr, Byte> imgChar1 = null;
            //Image<Bgr, Byte> imgChar2 = null;
            //Image<Bgr, Byte> imgChar3 = null;
            //Image<Bgr, Byte> imgChar4 = null;
            //Image<Bgr, Byte> imgChar5 = null;
            //Image<Bgr, Byte> imgChar6 = null;
            Rectangle loc;
            Rectangle lp1;
            Rectangle lp2;
            Rectangle lp3;
            Rectangle lp4;
            Rectangle lp5;
            Rectangle lp6;

            string l1;
            string l2;
            string l3;
            string l4;
            string l5;
            string l6;
            string l7;
            string l8;
            string l9;

            ImageClass.LP_Recognition(img, imgUndo, out loc, out lp1, out lp2, out lp3, out lp4, out lp5, out lp6, out l1, out l2, out l3, out l4, out l5, out l6, out l7, out l8, out l9);


            Console.Write(l1);
            Console.Write(l2);

            //Image<Bgr, Byte> test = imgPlate.Copy();
            //ImageClass.ConvertToBW(test, 100);
            img = imgUndo.Copy();

            img.Draw(loc, new Bgr(Color.Red), 1);
            img.Draw(lp1, new Bgr(Color.Red), 1);
            img.Draw(lp2, new Bgr(Color.Red), 1);
            img.Draw(lp3, new Bgr(Color.Red), 1);
            img.Draw(lp4, new Bgr(Color.Red), 1);
            img.Draw(lp5, new Bgr(Color.Red), 1);
            img.Draw(lp6, new Bgr(Color.Red), 1);

            Console.Write("-" + l3 + l4 + "-" + l5 + l6);
            ImageViewer.SizeMode = PictureBoxSizeMode.Zoom;
            ImageViewer.Dock     = DockStyle.Fill;
            ImageViewer.Image    = img.Bitmap;
            ImageViewer.Refresh(); // atualiza imagem no ecrã
            Cursor = Cursors.Default;
        }
Exemplo n.º 20
0
        private void RotationToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (img == null) // verify if the image is already opened
            {
                return;
            }
            Cursor = Cursors.WaitCursor; // clock cursor

            InputBox input = new InputBox("Degrees:");

            input.ShowDialog();
            double degrees = Convert.ToDouble(input.ValueTextBox.Text);

            //convert to rads
            double rad_degrees = degrees * Math.PI / 180;

            //copy Undo Image
            imgUndo = img.Copy();

            Image <Bgr, Byte> imgCopy = img.Clone();

            ImageClass.Rotation(img, imgCopy, rad_degrees);

            ImageViewer.Image = imgCopy.Bitmap;
            ImageViewer.Refresh();    // refresh image on the screen

            Cursor = Cursors.Default; // normal cursor
        }
Exemplo n.º 21
0
        //Função que encontra os digitos
        private void digitosToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (img == null) // verify if the image is already opened
            {
                return;
            }
            Cursor = Cursors.WaitCursor; // clock cursor

            //copy Undo Image
            imgUndo = img.Copy();

            MIplImage s = imgUndo.MIplImage;

            //char "r";

            ImageClass.Digits(img);
            String b = ImageClass.EvaluateCompNumber();

            //Console.WriteLine(b);

            ImageViewer.Image = img.Bitmap;
            ImageViewer.Refresh();    // refresh image on the screen

            Cursor = Cursors.Default; // normal cursor
        }
Exemplo n.º 22
0
        private void MeanToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form1 Gui = new Form1();

            Gui.ShowDialog();

            float[,] matrix = Gui.matrix;
            float weight = Gui.weight_T;



            if (img == null) // verify if the image is already opened
            {
                return;
            }

            //copy Undo Image
            imgUndo = img.Copy();

            Image <Bgr, Byte> imgCopy = img.Clone();

            ImageClass.NonUniform(img, imgCopy, matrix, weight);

            ImageViewer.Image = img.Bitmap;
            ImageViewer.Refresh();    // refresh image on the screen

            Cursor = Cursors.Default; // normal cursor
        }
Exemplo n.º 23
0
        private void zoomXYToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (img == null) // verify if the image is already opened
            {
                return;
            }


            //copy Undo Image
            imgUndo = img.Copy();
            Cursor  = Cursors.WaitCursor; // clock cursor

            InputBox form = new InputBox("Qual o valor de Zoom?");

            form.ShowDialog();
            //float scaleFactor = (float)Convert.ToDecimal(form.ValueTextBox.Text);
            float scaleFactor = float.Parse(form.ValueTextBox.Text);

            //get mouse coordinates using mouseclick event
            mouseFlag = true;
            while (mouseFlag) //wait for mouseclick
            {
                Application.DoEvents();
            }

            //apply the zoom
            ImageClass.Scale_point_xy(img, imgUndo, scaleFactor, mouseX, mouseY);


            ImageViewer.Image = img.Bitmap;
            ImageViewer.Refresh();    // refresh image on the screen

            Cursor = Cursors.Default; // normal cursor
        }
Exemplo n.º 24
0
        private void ZoomToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (img == null) // verify if the image is already opened
            {
                return;
            }

            Cursor = Cursors.WaitCursor; // clock cursor

            InputBox input = new InputBox("Scale Factor:");

            input.ShowDialog();
            double scale_factor = Convert.ToDouble(input.ValueTextBox.Text);

            mouseFlag = true;
            while (mouseFlag)
            {
                Application.DoEvents();
            }

            //copy Undo Image
            imgUndo = img.Copy();

            Image <Bgr, Byte> imgCopy  = img.Clone();
            float             scale_ff = (float)Math.Round(scale_factor);

            ImageClass.Scale_point_xy(img, imgCopy, scale_ff, mouseX, mouseY);

            ImageViewer.Image = img.Bitmap;
            ImageViewer.Refresh();    // refresh image on the screen

            Cursor = Cursors.Default; // normal cursor
        }
Exemplo n.º 25
0
        private void projectionYToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (img == null) // verify if the image is already opened
            {
                return;
            }
            Cursor = Cursors.WaitCursor; // clock cursor

            //copy Undo Image
            imgUndo = img.Copy();

            MIplImage s      = imgUndo.MIplImage;
            int       height = s.height;


            Project_Y form = new Project_Y(ImageClass.Projection_Y(imgUndo), height);

            form.ShowDialog();


            ImageViewer.Image = img.Bitmap;
            ImageViewer.Refresh();    // refresh image on the screen

            Cursor = Cursors.Default; // normal cursor
        }
Exemplo n.º 26
0
        private void translationToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (img == null) // verify if the image is already opened
            {
                return;
            }
            Cursor = Cursors.WaitCursor; // clock cursor

            //copy Undo Image
            imgUndo = img.Copy();

            DoubleInputBox dib = new DoubleInputBox("X Translation:", "Y Translation:", "Translation", numberTextBox, numberTextBox);

            dib.ShowDialog();

            int dx = Convert.ToInt32(dib.textBox1.Text);
            int dy = Convert.ToInt32(dib.textBox2.Text);

            if (dib.DialogResult == DialogResult.OK)
            {
                ImageClass.Translation(img, img.Copy(), dx, dy);

                ImageViewer.Image = img.Bitmap;
                ImageViewer.Refresh(); // refresh image on the screen
            }

            Cursor = Cursors.Default; // normal cursor
        }
Exemplo n.º 27
0
        private void TranslationToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (img == null) // verify if the image is already opened
            {
                return;
            }
            Cursor = Cursors.WaitCursor; // clock cursor

            //copy Undo Image
            imgUndo = img.Copy();

            InputBox form = new InputBox("dX?");

            form.ShowDialog();
            int dx = Convert.ToInt32(form.ValueTextBox.Text);

            InputBox form2 = new InputBox("dY?");

            form2.ShowDialog();
            int dy = Convert.ToInt32(form2.ValueTextBox.Text);

            ImageClass.Translation(img, imgUndo, dx, dy);

            ImageViewer.Image = img.Bitmap;
            ImageViewer.Refresh();    // refresh image on the screen

            Cursor = Cursors.Default; // normal cursor
        }
Exemplo n.º 28
0
        private void nonUniformFiltersToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (img == null) // verify if the image is already opened
            {
                return;
            }

            //copy Undo Image
            imgUndo = img.Copy();

            WeightMatrix wm = new WeightMatrix();

            if (wm.ShowDialog() == DialogResult.OK)
            {
                float[,] mat = { { Convert.ToInt32(wm.topleft.Text),
                                   Convert.ToInt32(wm.top.Text),
                                   Convert.ToInt32(wm.topright.Text) },
                                 { Convert.ToInt32(wm.left.Text),
                                   Convert.ToInt32(wm.middle.Text),
                                   Convert.ToInt32(wm.right.Text) },
                                 { Convert.ToInt32(wm.bttmleft.Text),
                                   Convert.ToInt32(wm.bottom.Text),
                                   Convert.ToInt32(wm.bttmright.Text) } };
                ImageClass.NonUniform(img, img.Copy(), mat, Convert.ToInt32(wm.weight.Text));
            }
            else
            {
                return;
            }
            ImageViewer.Image = img.Bitmap;
            ImageViewer.Refresh(); // refresh image on the screen
        }
Exemplo n.º 29
0
        private void BrightnessToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (img == null) // verify if the image is already opened
            {
                return;
            }
            Cursor = Cursors.WaitCursor; // clock cursor

            //input boxes
            InputBox form = new InputBox("brightness?");

            form.ShowDialog();
            int brightness = Convert.ToInt32(form.ValueTextBox.Text);

            InputBox formc = new InputBox("contrast?");

            formc.ShowDialog();
            float contrast = Convert.ToInt32(formc.ValueTextBox.Text);


            //copy Undo Image
            imgUndo = img.Copy();



            ImageClass.BrightContrast(img, brightness, contrast);

            ImageViewer.Image = img.Bitmap;
            ImageViewer.Refresh();    // refresh image on the screen

            Cursor = Cursors.Default; // normal cursor
        }
Exemplo n.º 30
0
        private void aula1ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int[] intensity = new int[256];
            int[] red       = new int[256];
            int[] green     = new int[256];
            int[] blue      = new int[256];

            if (img == null) // protege de executar a função sem ainda ter aberto a imagem
            {
                return;
            }

            Cursor = Cursors.WaitCursor; // cursor relogio
            DateTime d1 = DateTime.Now;

            ImageClass.histogram(img, intensity, red, green, blue, 3);
            Form CompTable = new CompressionTableForm(intensity, img);

            CompTable.Show();

            ImageViewer.Refresh(); // atualiza imagem no ecrã
            DateTime d2 = DateTime.Now;

            Cursor = Cursors.Default; // cursor normal
            MessageBox.Show((d2 - d1).ToString());
        }