コード例 #1
0
ファイル: FillDB.cs プロジェクト: Forpatril/Diploma
 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++);
     }
 }
コード例 #2
0
ファイル: Form1.cs プロジェクト: Forpatril/Diploma
        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);
            }

        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: Forpatril/Diploma
        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();
        }