コード例 #1
0
 public void Drawer_NullReadonlyVoronoi_IOException()
 {
     ReadonlyBitmap.Set(null);
     using (var writer = new Drawer(new Bitmap(10, 10)))
     {
         writer.DrawVoronoi(Fortunes.Run(9, 9, new Point2D[] {}));
     }
 }
コード例 #2
0
 public void Drawer_HappyPath_IsHappy()
 {
     ReadonlyBitmap.Set(new Bitmap(10, 10));
     using (var writer = new Drawer(ReadonlyBitmap.Get()))
     {
         writer.DrawVoronoi(Fortunes.Run(9, 9, new[] { new Point2D(0, 0), new Point2D(5, 5) }));
         writer.SaveToNewImageFile("a.png", Directory.GetCurrentDirectory());
         writer.SaveToNewImageFile("a.png", Directory.GetCurrentDirectory());
     }
 }
コード例 #3
0
        public void CalculateRegionsDeltaEList_SameImage_ExpectZero()
        {
            var originalBitmap = new Bitmap(TestImageDirectory + "WhitePicture_test.png");

            ReadonlyBitmap.Set(originalBitmap);
            var squareRegionofPoints = GetIntPoint2DListOfRegion();
            var site          = new IntPoint2D(25, 25);
            var imageComparer = new ImageComparer();

            var allDeltaEList = imageComparer.CalculateRegionsDeltaEList(ReadonlyBitmap.Get(), squareRegionofPoints, site);

            Assert.AreEqual(0.0, allDeltaEList.Average());
        }
コード例 #4
0
ファイル: Runner.cs プロジェクト: aaronchun7/C-Voronoi
        private static void Run(int iterations, Bitmap newImage, string fileName, string fileDirectory, int numberOfPointsToPlot)
        {
            ReadonlyBitmap.Set(newImage);
            var nums   = Enumerable.Range(0, iterations).ToArray();
            var result = new ConcurrentDictionary <VoronoiOutput, double>();

            Parallel.ForEach(nums, _ =>
            {
                var voronoiOutput = Fortunes.Run(ReadonlyBitmap.Get().Width, ReadonlyBitmap.Get().Height, numberOfPointsToPlot);
                var averageDeltaE = voronoiOutput.CalculateAccuracy();
                result.TryAdd(voronoiOutput, averageDeltaE);
            });
            var bestVoronoi = result.Aggregate((l, r) => l.Value < r.Value ? l : r).Key;

            using (var writer = new Drawer(newImage))
            {
                writer.DrawVoronoi(bestVoronoi);
                writer.SaveToNewImageFile(fileName, fileDirectory);
            }
        }