public void ScaleWithGuassianSampler_CanScaleAnImageCorrectly() { var pgmImage = PgmService.Read(Resources.chairs); var scaledImage = _imageScaler.ScaleWithGuassianSampler(pgmImage, ScaleFactor, SigmaScaleFactor); var newPgmImage = PgmService.Write(scaledImage); var path = Path.Combine(Directory.GetCurrentDirectory(), $"ImageScalerTest-{Guid.NewGuid()}.pgm"); File.WriteAllBytes(path, newPgmImage); }
public void LoadTest() { var pgmImage = PgmService.Read(Resources.chairs); var stopWatch = new Stopwatch(); stopWatch.Start(); const int numberOfRuns = 20; for (var i = 0; i < numberOfRuns; i++) { _imageScaler.ScaleWithGuassianSampler(pgmImage, ScaleFactor, SigmaScaleFactor); } stopWatch.Stop(); var perSecond = numberOfRuns / (stopWatch.ElapsedMilliseconds / 1000); Console.WriteLine($"Took {stopWatch.ElapsedMilliseconds}ms, running at {perSecond} scalings per second"); }
public void Run_SuccessfullyIdentifiesLineSegments() { var pgmImage = PgmService.Read(Resources.chairs); var result = _lineSegmentDetector.Run(pgmImage); var lineImage = result.Item2; // Any non-zero value in the image is a line. Convert this to black and white // by simply setting the maximum value for all lines. var outputImage = new Image <double, int>(lineImage.Width, lineImage.Height, 1); for (var x = 0; x < outputImage.Width; x++) { for (var y = 0; y < outputImage.Height; y++) { outputImage[x, y] = lineImage[x, y] > 0 ? 1 : 0; } } var newPgmImage = PgmService.Write(outputImage); var path = Path.Combine(Directory.GetCurrentDirectory(), $"LineSegmentDetectionTest-{Guid.NewGuid()}.pgm"); File.WriteAllBytes(path, newPgmImage); }