Example #1
0
        public static void Analyze(System.ComponentModel.BackgroundWorker worker)
        {
            int i = 0;
            foreach (string file in Directory.GetFiles("C:\\Users\\Forpatril\\Documents\\Visual Studio 2010\\Projects\\Diploma_cs\\Images", "*.jpg"))
            {
                Image img = new Image(file);
                for (int w = 2; w < 35; w++)
                    for (int sig = 1; sig < w / 2; sig++)
                    {
                        filterclass fc = new filterclass();
                        Noise n = new Noise();
                        Image img_n = n.addNoise("gaussian", img, 0, 0.055);
                        double[] p = new double[] {w, sig, 0.2};
                        MWNumericArray parameters = new MWNumericArray(p);
                        MWLogicalArray mw_print = new MWLogicalArray(Form1.print);
                        MWArray[] Result = fc.filter2(2, img_n.image, "bilateral", parameters, mw_print);
                        MWNumericArray descriptor = null;
                        descriptor = (MWNumericArray)Result[0];
                        double[,] result = null;
                        result = (double[,])descriptor.ToArray(MWArrayComponent.Real);
                        Image ret = new Image(result);
                        MWNumericArray e_descriptor = null;
                        e_descriptor = (MWNumericArray)Result[1];
                        ret.Time = (double)e_descriptor.ToScalarDouble();

                        filterDataContext db = new filterDataContext();
                        psnrClass ps = new psnrClass();
                        double psnr = (double)((MWNumericArray)ps.psnr(ret.image, img.image)).ToScalarDouble();
                        db.add_line("bilateral", "gaussian", img.Height, img.Width, ret.Time, psnr, p[0], p[1], p[2]);


                        Result = null;
                        e_descriptor = null;
                        result = null;
                        parameters = null;
                        img_n = null;
                        n = null;
                        descriptor = null;
                        ret = null;
                        ps = null;
                        fc = null;
                        GC.Collect();
                    }
                worker.ReportProgress(i++);
                img = null;
                GC.Collect();
            }
        }
Example #2
0
 public static void Fill(string path, int id, System.ComponentModel.BackgroundWorker worker)
 {
     int i = 0;
     foreach (string file in Directory.GetFiles(path, "*.jpg"))
     {
         filterDataContext db = new filterDataContext();
         Image img = new Image(file);
         Noise n = new Noise();
         img = n.addNoise("gaussian", img, 0, 0.055);
         RunFilter rf = new RunFilter();
         Image ret = rf.Do(img, id);
         psnrClass ps = new psnrClass();
         double psnr = (double)((MWNumericArray)ps.psnr(ret.image, img.image)).ToScalarDouble();
         db.add_line(Filters.type[id],"gaussian",img.Height,img.Width,ret.Time,psnr,Form1.pars.par[id][0],Form1.pars.par[id][1],Form1.pars.par[id][2]);
         worker.ReportProgress(i++);
     }
 }
Example #3
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);

        }
Example #4
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);
            }

        }