public void Should_Build_Proper_Mapping() { var testName = "InpaintMapBuilderTest"; var ts = TestSet.Init("256x128"); // create map var mapBuilder = new InpaintMapBuilder(); var imageArea = Area2D.Create(0, 0, ts.Picture.Width, ts.Picture.Height); mapBuilder.InitNewMap(imageArea); var inpaintArea = ts.RemoveMarkup.ToArea(); mapBuilder.SetInpaintArea(inpaintArea); for (int i = 0; i < ts.Donors.Count; i++) { var donorArea = ts.Donors[i].ToArea(); mapBuilder.AddDonor(donorArea); } var sw = new Stopwatch(); sw.Restart(); var mapping = mapBuilder.Build(); sw.Stop(); // convert mapping to areas var areaPairs = (mapping as IAreasMapping).AssociatedAreasAsc; for (int i = 0; i < areaPairs.Length; i++) { var areaPair = areaPairs[i]; SaveToOutput(areaPair.Item1, $"dest{i}", testName, ts.Path, Color.Red); SaveToOutput(areaPair.Item2, $"src{i}", testName, ts.Path, Color.Green); } // compare output and references string[] reffiles = Directory.GetFiles($"{ts.Path}\\{testName}\\refs", "*.*", SearchOption.TopDirectoryOnly); string[] outfiles = Directory.GetFiles($"{ts.Path}\\{testName}\\output", "*.*", SearchOption.TopDirectoryOnly); reffiles.Length.ShouldBe(outfiles.Length); if (reffiles.Length != outfiles.Length) { foreach (var refFilePath in reffiles) { var refFileName = Path.GetFileName(refFilePath); var outFilePath = $"{ts.Path}\\{testName}\\output\\{refFileName}"; File.Exists(outFilePath).ShouldBeTrue(); var refArea = new Bitmap(refFilePath).ToArea(); var outArea = new Bitmap(outFilePath).ToArea(); refArea.IsSameAs(outArea).ShouldBeTrue(); } } }
public void Should_Build_Proper_Mapping_Fast() { var ts = TestSet.Init("1280x720"); // create map var mapBuilder = new InpaintMapBuilder(); var imageArea = Area2D.Create(0, 0, ts.Picture.Width, ts.Picture.Height); mapBuilder.InitNewMap(imageArea); var inpaintArea = ts.RemoveMarkup.ToArea(); mapBuilder.SetInpaintArea(inpaintArea); for (int i = 0; i < ts.Donors.Count; i++) { var donorArea = ts.Donors[i].ToArea(); mapBuilder.AddDonor(donorArea); } var sw = new Stopwatch(); sw.Restart(); mapBuilder.Build(); sw.Stop(); sw.ElapsedMilliseconds.ShouldBeLessThan(800); }
public static TestSet Init(string size) { TestSet ts = new TestSet(); ts.Path = System.IO.Path.GetFullPath(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $@"..\..\images\{size}")); ts.Picture = new Bitmap($"{ts.Path}\\picture.jpg"); ts.RemoveMarkup = new Bitmap($"{ts.Path}\\inapaintarea.png"); var donors = new List <Bitmap>(); donors.Add(new Bitmap($"{ts.Path}\\donor00.png")); donors.Add(new Bitmap($"{ts.Path}\\donor01.png")); donors.Add(new Bitmap($"{ts.Path}\\donor02.png")); donors.Add(new Bitmap($"{ts.Path}\\donor03.png")); donors.Add(new Bitmap($"{ts.Path}\\donor04.png")); ts.Donors = donors; return(ts); }