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); }
public void RunLBPCalculateBatch_MRE_png_EqualsReference() { var runlbp = new RunLBP(load + @"\Test5", save + @"\Test5"); Directory.CreateDirectory(@"C:\temp\test\load\Test5"); Directory.CreateDirectory(@"C:\temp\test\save\Test5"); runlbp.param.Mre = true; runlbp.param.Scale = false; runlbp.param.W_stand = new int[] { 5, 3, 2, 1 }; testImg.New("Quarters", new int[] { 28, 28 }); Functions.Save(load + @"\Test5\Test1.png", testImg.Image.ToDouble(), false); Functions.Save(load + @"\Test5\Test2.png", testImg.Image.ToDouble(), false); Functions.Save(load + @"\Test5\Test3.png", testImg.Image.ToDouble(), false); runlbp.CalculateBatch(); float[,] result1 = Functions.Load(save + @"\Test5\Test1_small.png"); float[,] result2 = Functions.Load(save + @"\Test5\Test2_small.png"); float[,] result3 = Functions.Load(save + @"\Test5\Test3_small.png"); 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, result1); Assert.Equal(refIS, result2); Assert.Equal(refIS, result3); }
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); }
public void RunLBP_DefaultInput_OutputsDefaultParameters() { var param = new Parameters(); var runlbp = new RunLBP(); // Write more assertions Assert.Equal(param.LargeRadius, runlbp.param.LargeRadius); Assert.Equal(param.Neighbours, runlbp.param.Neighbours); Assert.Equal(param.Save, runlbp.param.Save); }
public static void Batch(Parameters param) { // Initialize paths string path = "", savepath = ""; // Select load path var fbd = new FolderBrowserDialog() { Description = "Select the directory to load images" }; if (fbd.ShowDialog() == DialogResult.OK) { path = fbd.SelectedPath; } else { Console.WriteLine("No directory selected.\n"); return; } // Select save path fbd = new FolderBrowserDialog() { Description = "Select the directory to save results" }; if (fbd.ShowDialog() == DialogResult.OK) { savepath = fbd.SelectedPath; } else { Console.WriteLine("No directory selected.\n"); return; } // Calculate batch of LBP images RunLBP run = new RunLBP() { path = path, // image path and result path savepath = savepath, param = param, // pipeline parameters }; run.CalculateBatch(); }
public void RunLBPCalculateBatch_LBP_dat_EqualsReference() { var runlbp = new RunLBP(load + @"\Test1", save + @"\Test1"); Directory.CreateDirectory(@"C:\temp\test\load\Test1"); Directory.CreateDirectory(@"C:\temp\test\save\Test1"); runlbp.param.Mre = false; runlbp.param.Scale = false; runlbp.param.W_stand = new int[] { 5, 3, 2, 1 }; runlbp.param.ImageType = ".dat"; // save images testImg.New("Quarters", new int[] { 12, 12 }); var bin = new BinaryWriterApp() { filename = load + @"\Test1\Test4.dat" }; bin.SaveBinary(testImg.Image.ToDouble()); bin.filename = load + @"\Test1\Test5.dat"; bin.SaveBinary(testImg.Image.ToDouble()); bin.filename = load + @"\Test1\Test6.dat"; bin.SaveBinary(testImg.Image.ToDouble()); runlbp.CalculateBatch(); float[,] result1 = Functions.Load(save + @"\Test1\Test4_LBP.png"); float[,] result2 = Functions.Load(save + @"\Test1\Test5_LBP.png"); float[,] result3 = Functions.Load(save + @"\Test1\Test6_LBP.png"); 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, result1); Assert.Equal(refIS, result2); Assert.Equal(refIS, result3); }
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); }
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(); }