Beispiel #1
0
        private void DoWork(object sender, DoWorkEventArgs e)
        {
            System.ComponentModel.BackgroundWorker worker;
            worker = (System.ComponentModel.BackgroundWorker)sender;

            int id = (int)e.Argument;
            if ((id % 100) / 10 == 0)
            {
                RunNoise rn = new RunNoise();
                rn.id = (id / 100) - 1;
                rn.a = par[(id / 100) - 1].a;
                rn.b = par[(id / 100) - 1].b;
                im[(id / 100) - 1] = rn.Do(image);
            }
            else if ((id % 100) / 10 == 1)
            {
                RunFilter rf = new RunFilter();
                Image ret = rf.Do(im[(id / 100) - 1], id % 10, (id / 100) - 1);
                psnrClass p = new psnrClass();
                MWArray ps = p.psnr(ret.image, image.image);
                psnr[(id / 100) - 1] = (double)((MWNumericArray)ps).ToScalarDouble();
                lb_res res = new lb_res();
                res.id = (id / 100) - 1;
                res.value = psnr[(id / 100) - 1].ToString("F2") + " " + ret.Time.ToString("F2");
                e.Result = res;
            }
            else if ((id % 100) / 10 == 2)
            {
                RunFilter rf = new RunFilter();
                Image ret = rf.Do(im[(id / 100) - 1], (id / 100) - 1, id % 10, 8);
                psnrClass p = new psnrClass();
                MWArray ps = p.psnr(ret.image, image.image);
                psnr[(id / 100) - 1] = (double)((MWNumericArray)ps).ToScalarDouble();
                lb_res res = new lb_res();
                res.id = (id / 100) + 6;
                res.value = psnr[(id / 100) - 1].ToString("F2") + " " + ret.Time.ToString("F2");
                //db.add_line(Filters.type[(id / 100) - 1], RunNoise.type[Form1.noise], ret.Height, ret.Width, ret.Time, psnr[(id / 100) - 1], pars.par[(id / 100) - 1][0], pars.par[(id / 100) - 1][1], pars.par[(id / 100) - 1][2]);
                e.Result = res;
            }
            else
            {
                //FillDB f = new FillDB();
                //f.Fill("C:\\Users\\Forpatril\\Documents\\Visual Studio 2010\\Projects\\Diploma_cs\\Images", id % 10, worker);
                if (id % 100 < 4)
                    FillDB.Fill("C:\\Users\\Forpatril\\Documents\\Visual Studio 2010\\Projects\\Diploma_cs\\Images", id % 10, worker);
                else
                    FillDB.Analyze(worker);
            }

        }
Beispiel #2
0
        private void button8_Click(object sender, EventArgs e)
        {
            string path = "D:\\Users\\Forpatril\\Documents\\Visual Studio 2010\\Projects\\Diploma_cs\\einstein.jpg";
            if (!checkBox1.Checked)
            {
                openFileDialog1.InitialDirectory = Application.StartupPath;
                if (openFileDialog1.ShowDialog() != DialogResult.OK) return;
                path = openFileDialog1.FileName;
            }
            image = new Image(path);

            if (image.Array == null)
            {
                MessageBox.Show("Цветное изображение, используйте изображение в градациях серого", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            path = "";

            pictureBox10.Image = image.Bitmap;
            RunNoise ns = new RunNoise();
            noise = ns.id = comboBox2.SelectedIndex;
            ns.a = par[comboBox2.SelectedIndex].a;
            ns.b = par[comboBox2.SelectedIndex].b;
            Image res = ns.Do(image, 7);

            psnrClass p = new psnrClass();
            MWArray ps = p.psnr(res.image, image.image);
            double pnr = ((double)((MWNumericArray)ps).ToScalarDouble());
            label36.Text = pnr.ToString();

            label3.Text = "";
            im.Clear();
            for (int i = 0; i < 11; i++)
                im.Add(res);
            backgroundWorker1.RunWorkerAsync(120);
            backgroundWorker2.RunWorkerAsync(221);
            backgroundWorker3.RunWorkerAsync(322);
            backgroundWorker4.RunWorkerAsync(423);
            backgroundWorker5.RunWorkerAsync(524);
            backgroundWorker6.RunWorkerAsync(625);
            backgroundWorker7.RunWorkerAsync(726);
            backgroundWorker8.RunWorkerAsync(827);
            backgroundWorker9.RunWorkerAsync(928);
            backgroundWorker10.RunWorkerAsync(1029);
            backgroundWorker11.RunWorkerAsync(1120);

        }
Beispiel #3
0
        private void button13_Click(object sender, EventArgs e)
        {
            int n, f;
            string path;
            Image wrk;
            if (checkBox2.Checked)
            {
                n = 2;
                f = 2;
                path = "D:\\Users\\Forpatril\\Documents\\Visual Studio 2010\\Projects\\Diploma_cs\\Images\\0dba4c83f4c7f864d9b7993545cfc.jpg";
            }
            else
            {
                n = ns;
                f = ft;
                if (checkBox1.Checked)
                    path = "D:\\Users\\Forpatril\\Documents\\Visual Studio 2010\\Projects\\Diploma_cs\\einstein.jpg";
                else
                {
                    openFileDialog1.InitialDirectory = Application.StartupPath;
                    if (openFileDialog1.ShowDialog() != DialogResult.OK) return;
                    path = openFileDialog1.FileName;
                }
            }
            wrk = new Image(path);

            if (wrk.Array == null)
            {
                MessageBox.Show("Цветное изображение, используйте изображение в градациях серого", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            path = "";

            pictureBox23.Image = wrk.Bitmap;
            RunNoise nois = new RunNoise();
            nois.a = par[n].a;
            nois.b = par[n].b;
            nois.id = n;
            wrk = nois.Do(wrk, true);
            pictureBox24.Image = wrk.Bitmap;
            RunFilter filt = new RunFilter();
            wrk = filt.Do(wrk, f);
            pictureBox25.Image = wrk.Bitmap;
            nois = null;
            wrk = null;
            filt = null;
            GC.Collect();
        }