Ejemplo n.º 1
0
        private void button5_Click(object sender, EventArgs e)
        {
            dataGridView1.ColumnCount = 0;

            Bitmap img1 = new Bitmap(filePath1);
            Bitmap img2 = new Bitmap(filePath2);

            int radius = 0;


            if (comboBox1.SelectedItem == null)
            {
                radius = 1;
            }
            else
            {
                radius = Convert.ToInt32(comboBox1.SelectedItem);
            }
            OutputWrapper outputWrapper = ConverterImg.Compare(img1, img2, radius);

            var rowCountY  = outputWrapper.BoolArr.GetLength(1);
            var rowLengthX = outputWrapper.BoolArr.GetLength(0);

            for (int i = 0; i < rowLengthX; i++)
            {
                dataGridView1.Columns.Add($"{i}", $"{i}");
                dataGridView1.Columns[i].Width = i.ToString().Length * 10;
            }

            for (int i = 0; i < outputWrapper.BoolArr.GetLength(1); i++)
            {
                var row = new DataGridViewRow();

                for (int j = 0; j < outputWrapper.BoolArr.GetLength(0); j++)
                {
                    row.Cells.Add(new DataGridViewTextBoxCell()
                    {
                        Value = Convert.ToInt16(outputWrapper.BoolArr[j, i])
                    });
                }
                dataGridView1.Rows.Add(row);
            }
            dataGridView1.Refresh();
        }
Ejemplo n.º 2
0
        private void button7_Click(object sender, EventArgs e)
        {
            using (Image image1 = new Bitmap(pictureBox1.Image))
                using (Image image2 = new Bitmap(pictureBox2.Image))
                    using (Image image3 = new Bitmap(pictureBox3.Image))
                    {
                        List <Image> images = new List <Image>();
                        images.Add(image1);
                        images.Add(image2);
                        images.Add(image3);

                        string appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
                        string outputPath  = $"{appDataPath}\\output.jpg";

                        ConverterImg.MergeImages(image1, image2, outputPath, image3);
                        ConverterImg.MergeImagesList(images, outputPath, System.Drawing.Imaging.ImageFormat.Jpeg);

                        images.Dispose();
                    }
        }
Ejemplo n.º 3
0
        private void button6_Click(object sender, EventArgs e)
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            int   radius            = 0;
            float percentageOfTruth = 0;

            if (comboBox1.SelectedItem == null)
            {
                radius = 1;
            }
            else
            {
                radius = Convert.ToInt32(comboBox1.SelectedItem);
            }
            if (comboBox2.SelectedItem == null)
            {
                percentageOfTruth = 0.01f;
            }
            else
            {
                percentageOfTruth = float.Parse(comboBox2.SelectedItem.ToString());
            }


            dataGridView1.ColumnCount = 0;
            Bitmap img1 = new Bitmap(filePath1);
            Bitmap img2 = new Bitmap(filePath2);

            OutputWrapper outputWrapper = ConverterImg.CompareWithTolerance(
                img1: img1,
                img2: img2,
                areaRadius: radius,
                percentageOfTruth: percentageOfTruth / 100);


            pictureBox3.Image = outputWrapper.Bitmap;


            var rowCountY  = outputWrapper.BoolArr.GetLength(1);
            var rowLengthX = outputWrapper.BoolArr.GetLength(0);

            for (int i = 0; i < rowLengthX; i++)
            {
                dataGridView1.Columns.Add($"{i}", $"{i}");
                dataGridView1.Columns[i].Width = i.ToString().Length * 10;
            }

            for (int i = 0; i < outputWrapper.BoolArr.GetLength(1); i++)
            {
                var row = new DataGridViewRow();

                for (int j = 0; j < outputWrapper.BoolArr.GetLength(0); j++)
                {
                    row.Cells.Add(new DataGridViewTextBoxCell()
                    {
                        Value = Convert.ToInt16(outputWrapper.BoolArr[j, i])
                    });
                }
                dataGridView1.Rows.Add(row);
            }
            dataGridView1.Refresh();
            textBox1.AppendText($"Pixel radius = {radius} with percentage of true valued cells:{percentageOfTruth}%{Environment.NewLine}");
            //textBox1.AppendText($"{outputWrapper.Numeric1} % simmilarity{Environment.NewLine}");
            textBox1.AppendText($"{outputWrapper.Percentage} % simmilarity{Environment.NewLine}out of {outputWrapper.AllPixels} pixels {outputWrapper.DifferentPixels} are different{Environment.NewLine}");
            //textBox1.AppendText($"{outputWrapper.Colors.Count} different colors detected in picture{Environment.NewLine}");

            //outputWrapper.ColorsSorted = Converter.ReturnSortedColors(outputWrapper).ColorsSorted;
            //outputWrapper.ColorsSorted = OutputWrapper.ReturnSortedColors(outputWrapper).ColorsSorted;
            //outputWrapper = new ConverterDependency().ReturnSortedColors(outputWrapper);

            //foreach (var item in outputWrapper.ColorsSorted)
            //{
            //    textBox1.AppendText($"{item}{Environment.NewLine}");
            //}


            textBox1.AppendText($"Parallel execution in {stopwatch.Elapsed}{Environment.NewLine}");
        }