Exemplo n.º 1
0
        public void RunLBPCalculateSingle_LBP_png_EqualsReference()
        {
            var runlbp = new RunLBP()
            {
                path     = load + @"\Test1.png",
                savepath = save
            };

            testImg.New("Quarters", new int[] { 12, 12 });
            Functions.Save(runlbp.path, testImg.Image.ToDouble(), false);
            runlbp.param.Mre       = false;
            runlbp.param.Scale     = false;
            runlbp.param.ImageType = ".png";

            runlbp.CalculateSingle();
            float[,] result = Functions.Load(save + @"\Test1_LBP.png");
            int[,] features = Functions.ReadCSV(save + @"\features.csv").ToInt32();

            float[,] refIS = new float[6, 6]
            {
                { 8, 8, 8, 5, 5, 5 },
                { 8, 8, 8, 5, 5, 6 },
                { 8, 8, 8, 5, 5, 6 },
                { 5, 6, 6, 3, 3, 3 },
                { 5, 6, 6, 3, 3, 3 },
                { 6, 6, 6, 3, 3, 3 }
            };
            Assert.Equal(refIS, result);
        }
Exemplo n.º 2
0
        public void RunLBPCalculateSingle_MRE_png_EqualsReference()
        {
            var runlbp = new RunLBP(load + @"\Test7\Test1.png", save + @"\Test7");

            Directory.CreateDirectory(@"C:\temp\test\load\Test7");
            Directory.CreateDirectory(@"C:\temp\test\save\Test7");

            testImg.New("Quarters", new int[] { 28, 28 });
            Functions.Save(runlbp.path, testImg.Image.ToDouble(), false);
            runlbp.param.Mre       = true;
            runlbp.param.Scale     = false;
            runlbp.param.W_stand   = new int[] { 5, 3, 2, 1 };
            runlbp.param.ImageType = ".png";
            Functions.Save(load + @"\Test7\Test1.png", testImg.Image.ToDouble(), false);

            runlbp.CalculateSingle();
            float[,] result = Functions.Load(save + @"\Test7\Test1_LBPIS.png");
            int[,] features = Functions.ReadCSV(save + @"\Test7\features.csv").ToInt32();

            float[,] refIS = new float[6, 6]
            {
                { 9, 7, 6, 6, 6, 1 },
                { 8, 1, 9, 6, 6, 1 },
                { 6, 2, 3, 6, 3, 1 },
                { 7, 5, 2, 5, 6, 2 },
                { 7, 2, 2, 9, 7, 8 },
                { 7, 2, 2, 2, 1, 9 }
            };
            Assert.Equal(refIS, result);
        }
Exemplo n.º 3
0
        public void RunLBPCalculateSingle_MRE_dat_EqualsReference()
        {
            var runlbp = new RunLBP(load + @"\Test6\Test1.dat", save + @"\Test6");

            Directory.CreateDirectory(@"C:\temp\test\load\Test6");
            Directory.CreateDirectory(@"C:\temp\test\save\Test6");

            testImg.New("Quarters", new int[] { 28, 28 });
            var bin = new BinaryWriterApp()
            {
                filename = load + @"\Test6\Test1.dat"
            };

            bin.SaveBinary(testImg.Image.ToDouble());
            runlbp.param.Mre       = true;
            runlbp.param.Scale     = false;
            runlbp.param.W_stand   = new int[] { 5, 3, 2, 1 };
            runlbp.param.ImageType = ".dat";

            runlbp.CalculateSingle();
            bin.filename    = save + @"\Test6\features.dat";
            float[,] result = Functions.Load(save + @"\Test6\Test1_LBPIS.png");
            bin.ReadLBPFeatures("uint32");
            int[,] features = bin.features;

            float[,] refIS = new float[6, 6]
            {
                { 9, 7, 6, 6, 6, 1 },
                { 8, 1, 9, 6, 6, 1 },
                { 6, 2, 3, 6, 3, 1 },
                { 7, 5, 2, 5, 6, 2 },
                { 7, 2, 2, 9, 7, 8 },
                { 7, 2, 2, 2, 1, 9 }
            };
            Assert.Equal(refIS, result);
        }
Exemplo n.º 4
0
        public static void Single(Parameters param)
        {
            // Initialize paths
            string path = "", savepath = "", meanpath = "", stdpath = "";

            if (param.Meanstd)
            {
                // Select mean image path
                var meanfile = new OpenFileDialog()
                {
                    Title = "Select mean image to be calculated"
                };
                if (meanfile.ShowDialog() == DialogResult.OK)
                {
                    meanpath = meanfile.FileName;
                }
                else
                {
                    Console.WriteLine("No directory selected.\n");
                    return;
                }

                // Select std image path
                var stdfile = new OpenFileDialog()
                {
                    Title = "Select std image to be calculated"
                };
                if (stdfile.ShowDialog() == DialogResult.OK)
                {
                    stdpath = stdfile.FileName;
                }
                else
                {
                    Console.WriteLine("No directory selected.\n");
                    return;
                }
            }
            else
            {
                // Select load path
                var openfile = new OpenFileDialog()
                {
                    Title = "Select the image to be calculated"
                };
                if (openfile.ShowDialog() == DialogResult.OK)
                {
                    path = openfile.FileName;
                }
                else
                {
                    Console.WriteLine("No directory selected.\n");
                    return;
                }
            }

            // Select save path
            var fbd = new FolderBrowserDialog()
            {
                Description = "Select the directory to save results"
            };

            if (fbd.ShowDialog() == DialogResult.OK)
            {
                savepath = fbd.SelectedPath;
            }
            else
            {
                Console.WriteLine("No save path selected.\n");
                savepath = null;
            }

            // Calculate single LBP image
            RunLBP run2 = new RunLBP()
            {
                path     = path,
                savepath = savepath,
                param    = param,
                meanpath = meanpath,
                stdpath  = stdpath
            };

            run2.CalculateSingle();
        }