コード例 #1
0
ファイル: B.cs プロジェクト: Forpatril/Diploma
        public Image RunFilter(Image src)
        {
            filterDataContext db = new filterDataContext();
            //Bilateral Bilateral = new Bilateral();
            double[] sigma = new double[] { 3, 0.1 };
            double w = 5;
            MWNumericArray mw_sigma = new MWNumericArray(sigma);
            //MWArray Result = Bilateral.bfilter2(image, w, mw_sigma);
            //MWArray image = new MWNumericArray(src.Array.Array);
            /*
            int H = src.Height;
            int W = src.Width;

            int sq = W * H;
            */
            MWArray[] Result = bilateral(2, src.image, w, mw_sigma);
            //MWArray[] Result = bfilter2(2, src.image, w, mw_sigma);
            MWNumericArray descriptor = null;
            descriptor = (MWNumericArray)Result[0];
            double[,] result = null;
            result = (double[,])descriptor.ToArray(MWArrayComponent.Real);
            Image res = new Image(result);
            MWNumericArray e_descriptor = null;
            e_descriptor = (MWNumericArray)Result[1];
            WorkTime = (double)e_descriptor.ToScalarDouble();
            db.add_b_res(src.Height, src.Height / src.Width, WorkTime, w, sigma[0], sigma[1]);
            Result = null;
            e_descriptor = null;
            result = null;
            mw_sigma = null;
            GC.Collect();
            return res;
        }
コード例 #2
0
ファイル: FillDB.cs プロジェクト: Forpatril/Diploma
        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();
            }
        }
コード例 #3
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++);
     }
 }
コード例 #4
0
ファイル: H.cs プロジェクト: Forpatril/Diploma
        public Image RunFilter(Image src)
        {
            filterDataContext db = new filterDataContext();
            //Bilateral Bilateral = new Bilateral();
            //double[] sigma = new double[] { 3, 0.1 };
            //double w = 5;
            //MWNumericArray mw_sigma = new MWNumericArray(sigma);
            //MWArray Result = Bilateral.bfilter2(image, w, mw_sigma);
            //MWNumericArray image = new MWNumericArray(src.Array.Array);
            MWArray[] Result = high(2, src.image);//Bilateral.bfilter2(2, image, w, mw_sigma);
            Image res = new Image((double[,])((MWNumericArray)Result[0]).ToArray(MWArrayComponent.Real));
            MWNumericArray e_descriptor = null;
            e_descriptor = (MWNumericArray)Result[1];
            WorkTime = (double)e_descriptor.ToScalarDouble();
            db.add_h_res(src.Height, src.Height / src.Width, WorkTime, 0.15);
            Result = null;
            e_descriptor = null;
            GC.Collect();
            return res;
            /*
            ihpf ihpf = new ihpf();
            Stopwatch stopwatch = new Stopwatch();
            stopwatch.Start();
            MWArray Result = ihpf.high(image);
            stopwatch.Stop();
            MWNumericArray descriptor = null;
            descriptor = (MWNumericArray)Result;
            Bitmap Image;
            double[,] d_descriptor = (double[,])descriptor.ToArray(MWArrayComponent.Real);
            Image = getImage(d_descriptor);

            Graphics g = pictureBox1.CreateGraphics();
            g.DrawImage(Image, 1, 1);
            label1.Text = stopwatch.Elapsed.ToString();
            isColor = false;
            db.add_h_res(Image.Height, Image.Height / Image.Width, stopwatch.ElapsedMilliseconds, 0.15);
             */
        }
コード例 #5
0
ファイル: Graph.cs プロジェクト: Forpatril/Diploma
        public GraphPane Draw(GraphPane pane, int id)
        {
            filterDataContext db = new filterDataContext();

            double t_max = (double)(from a in db.Datas where (a.ftype == type[id]) && (a.ftype == "gaussian") select a.p_time).Max();
            double t_min = (double)(from a in db.Datas where (a.ftype == type[id]) && (a.ftype == "gaussian") select a.p_time).Min();
            double p_max = (double)(from a in db.Datas where (a.ftype == type[id]) && (a.ftype == "gaussian") select a.psnr).Max();
            double p_min = (double)(from a in db.Datas where (a.ftype == type[id]) && (a.ftype == "gaussian") select a.psnr).Min();
            double w_max = (double)(from a in db.Datas where (a.ftype == type[id]) && (a.ftype == "gaussian") select a.p1).Max();
            double w_min = (double)(from a in db.Datas where (a.ftype == type[id]) && (a.ftype == "gaussian") select a.p1).Min();

            pane.Title.Text = "Анализ продолжительности вычислений";
            pane.CurveList.Clear();
            pane.YAxis.Scale.Min = p_min;
            pane.YAxis.Scale.Max = p_max;
            pane.YAxis.Title.Text = "PSNR";
            pane.XAxis.Title.Text = "Время обработки";
            pane.XAxis.Scale.Min = t_min;
            pane.XAxis.Scale.Max = t_max;
            pane.Y2Axis.Scale.Min = w_min;
            pane.Y2Axis.Scale.Max = w_max;
            pane.Y2Axis.Title.Text = "Размер окна фильтра";

            PointPairList List1 = new PointPairList(); 
            PointPairList List2 = new PointPairList();

            var query = from a in db.Datas where (a.ftype == type[id]) && (a.ftype == "gaussian") select a;
            foreach (var test in query)
            {
                List1.Add((double)test.p_time, (double)test.psnr);
                List2.Add((double)test.p_time, (double)test.p1);
            }
            LineItem Curve1 = pane.AddCurve("", List1, Color.Blue, SymbolType.None);

            LineItem Curve2 = pane.AddCurve("", List2, Color.Blue, SymbolType.None);

            return pane;
        }
コード例 #6
0
ファイル: Filters.cs プロジェクト: Forpatril/Diploma
 public Image RunFilter(Image src, int id)
 {
     filterDataContext db = new filterDataContext();
     double[] p = new double[Form1.pars.par[id].Length];
     p = Form1.pars.par[id];
     MWNumericArray parameters = new MWNumericArray(p);
     MWLogicalArray mw_print = new MWLogicalArray(Form1.print);
     MWArray[] Result = filter2(2, src.image, type[id], parameters, mw_print);
     MWNumericArray descriptor = null;
     descriptor = (MWNumericArray)Result[0];
     double[,] result = null;
     result = (double[,])descriptor.ToArray(MWArrayComponent.Real);
     Image res = new Image(result);
     MWNumericArray e_descriptor = null;
     e_descriptor = (MWNumericArray)Result[1];
     res.Time = WorkTime = (double)e_descriptor.ToScalarDouble();
     //db.add_b_res(src.Height, src.Height / src.Width, WorkTime, w, sigma[0], sigma[1]);
     Result = null;
     e_descriptor = null;
     result = null;
     parameters = null;
     GC.Collect();
     return res;
 }
コード例 #7
0
ファイル: Form1.cs プロジェクト: Forpatril/Diploma
 public Form1()
 {
     InitializeComponent();
     label1.Text = "";
     label2.Text = "";
     label3.Text = "";
     tabControl1.SelectTab(tabPage2);
     run = new bool[] { false, false, false };
     im = new List<Image>(11);
     pb_array = new List<PictureBox>();
     pb_array.Add(pictureBox3);
     pb_array.Add(pictureBox4);
     pb_array.Add(pictureBox5);
     pb_array.Add(pictureBox6);
     pb_array.Add(pictureBox7);
     pb_array.Add(pictureBox8);
     pb_array.Add(pictureBox9);
     pb_array.Add(pictureBox11);
     pb_array.Add(pictureBox12);
     pb_array.Add(pictureBox13);
     pb_array.Add(pictureBox14);
     pb_array.Add(pictureBox15);
     pb_array.Add(pictureBox16);
     pb_array.Add(pictureBox17);
     pb_array.Add(pictureBox18);
     pb_array.Add(pictureBox19);
     pb_array.Add(pictureBox20);
     pb_array.Add(pictureBox21);
     pb_array.Add(pictureBox22);
     comboBox1.SelectedIndex = 0;
     comboBox2.SelectedIndex = 1;
     comboBox3.SelectedIndex = 0;
     par = new List<param>(7);
     par.Add(new param(0, 0.055));
     par.Add(new param(0, 0.055));
     par.Add(new param(0.04, 0.04));
     par.Add(new param(0.6, 0.25));
     par.Add(new param(0, 0.055));
     par.Add(new param(12.6, 0.055));
     par.Add(new param(12.6, 3));
     pars = new Parameters();
     npars = new NoiseParameters();
     psnr = new double[11];
     lb_array = new List<System.Windows.Forms.Label>();
     lb_array.Add(label17);
     lb_array.Add(label18);
     lb_array.Add(label19);
     lb_array.Add(label20);
     lb_array.Add(label21);
     lb_array.Add(label22);
     lb_array.Add(label23);
     lb_array.Add(label24);
     lb_array.Add(label25);
     lb_array.Add(label26);
     lb_array.Add(label27);
     lb_array.Add(label28);
     lb_array.Add(label29);
     lb_array.Add(label30);
     lb_array.Add(label31);
     lb_array.Add(label32);
     lb_array.Add(label33);
     lb_array.Add(label34);
     db = new filterDataContext();
 }
コード例 #8
0
ファイル: Form1.cs プロジェクト: Forpatril/Diploma
        /*
        private Bitmap getImage(double[,] image)
        {
            int w = image.GetLength(1);
            int h = image.GetLength(0);
            Bitmap r_image = new Bitmap(w, h);
            for (int i = 0; i < h; i++)
            {
                for (int j = 0; j < w; j++)
                {
                    byte pixel = (byte)(image[i, j] * 255);
                    Color color = Color.FromArgb(255, pixel, pixel, pixel);
                    r_image.SetPixel(j, i, color);
                }
            }
            return r_image;
        }

        private Bitmap getImage(double[, ,] image)
        {
            int w = image.GetLength(2);
            int h = image.GetLength(1);
            Bitmap r_image = new Bitmap(w, h);
            for (int i = 0; i < h; i++)
            {
                for (int j = 0; j < w; j++)
                {
                    byte r = (byte)(image[0, i, j] * 255);
                    byte g = (byte)(image[1, i, j] * 255);
                    byte b = (byte)(image[2, i, j] * 255);
                    Color color = Color.FromArgb(255, r, g, b);
                    r_image.SetPixel(j, i, color);
                }
            }
            return r_image;
        }
        */

        private void button3_Click(object sender, EventArgs e)
        {
            B b = new B();
            Noise n = new Noise();
            Image res = n.addNoise("gaussian", image, 0, 0.055);
            pictureBox1.Image = res.Bitmap;
            Application.DoEvents();
            res = b.RunFilter(res);

            //Bilateral Bilateral = new Bilateral();
            //double[] sigma = new double[] {3, 0.1};
            //double w = 5;
            //MWNumericArray mw_sigma = new MWNumericArray(sigma);
            //Stopwatch stopwatch = new Stopwatch();
            //stopwatch.Start();
            ////MWArray Result = Bilateral.bfilter2(image, w, mw_sigma);
            //MWArray[] Result = Bilateral.bfilter2(2, image, w, mw_sigma);
            //stopwatch.Stop();
            //MWNumericArray descriptor = null;
            //descriptor = (MWNumericArray)Result[0];
            //MWNumericArray e_descriptor = null;
            //e_descriptor = (MWNumericArray)Result[1];
            //double Elapsed = (double)e_descriptor.ToScalarDouble();
            //Bitmap Image;
            //if (!isColor)
            //{
            //    double[,] d_descriptor = (double[,])descriptor.ToArray(MWArrayComponent.Real);
            //    Image = getImage(d_descriptor);
            //}
            //else
            //{
            //    double[,,] d_descriptor = (double[, ,])descriptor.ToArray(MWArrayComponent.Real);
            //    Image = getImage(d_descriptor);
            //}
            //pictureBox1.Size.Height = res.Height;
            //pictureBox1.Size.Width = res.Width;

            pictureBox1.Image = res.Bitmap;
            //label1.Text = stopwatch.Elapsed.ToString();
            //label2.Text = Elapsed.ToString();
            filterDataContext db = new filterDataContext();
            label1.Text = b.WorkTime.ToString();
            db.add_b_res(res.Height, res.Height / res.Width, b.WorkTime, 5, 3, 0.1);
            //isColor = false;
            b = null;
            n = null;
            res = null;
            GC.Collect();
        }
コード例 #9
-1
ファイル: Filters.cs プロジェクト: Forpatril/Diploma
 public Image RunFilter(Image src)
 {
     filterDataContext db = new filterDataContext();
     double[] sigma = new double[] { 3.0, 3.0 };
     MWNumericArray mw_sigma = new MWNumericArray(sigma);
     MWLogicalArray mw_print = new MWLogicalArray(Form1.print);
     MWArray[] Result = filter2(2, src.image, type[2], mw_print);//spfilt(2, src.image, "median");
     MWNumericArray descriptor = null;
     descriptor = (MWNumericArray)Result[0];
     double[,] result = null;
     result = (double[,])descriptor.ToArray(MWArrayComponent.Real);
     Image res = new Image(result);
     MWNumericArray e_descriptor = null;
     e_descriptor = (MWNumericArray)Result[1];
     WorkTime = (double)e_descriptor.ToScalarDouble();
     //db.add_b_res(src.Height, src.Height / src.Width, WorkTime, w, sigma[0], sigma[1]);
     Result = null;
     e_descriptor = null;
     result = null;
     mw_sigma = null;
     GC.Collect();
     return res;
 }