public void GetBorderCoordinates(byte[,] input, bool borderIsVertical, Point[] expected) { int[][] diffs = ImageProcessor.GetDifferenceOnDirection(input, borderIsVertical); var result = ImageProcessor.GetBorderCoordinates(diffs, borderIsVertical); CollectionAssert.AreEqual(expected, result); }
private static void OutputBorder(Bitmap picture, Dictionary <ImageProcessor.ResultingValue, byte[, ]> valueBytes, string fileFolder, string name, string fileInfoString) { byte[,] bytes; int[][] diffs; Point[] points; StreamWriter swPoints = new StreamWriter(pointsFile, true); swPoints.WriteLine(DateTime.Now + " " + fileInfoString); swPoints.Close(); foreach (ImageProcessor.ResultingValue mode in valueBytes.Keys) { if (valueBytes.TryGetValue(mode, out bytes)) { diffs = ImageProcessor.GetDifferenceOnDirection(bytes, true); PrintDifferencesTableToFile(diffs, true, mode.ToString(), "vertical"); points = ImageProcessor.GetBorderCoordinates(diffs, true); ShowBorderOnImage(picture, points, fileFolder, name, "vertical " + mode); PrintBorderPointsToFile(points, mode.ToString(), "vertical"); //diffs = ImageProcessor.GetDifferenceBeforeOnDirection(bytes, true); //PrintDifferencesTableToFile(diffs, true, mode.ToString(), "vertical before"); //points = ImageProcessor.GetBorderCoordinates(diffs, true); //ShowBorderOnImage(picture, points, fileFolder, name, "vertical before" + mode); //PrintBorderPointsToFile(points, mode.ToString(), "vertical before"); //diffs = ImageProcessor.GetDifferenceAfterOnDirection(bytes, true); //PrintDifferencesTableToFile(diffs, true, mode.ToString(), "vertical after"); //points = ImageProcessor.GetBorderCoordinates(diffs, true); //ShowBorderOnImage(picture, points, fileFolder, name, "vertical after" + mode); //PrintBorderPointsToFile(points, mode.ToString(), "vertical after"); diffs = ImageProcessor.GetDifferenceOnDirection(bytes, false); PrintDifferencesTableToFile(diffs, false, mode.ToString(), "horizontal"); points = ImageProcessor.GetBorderCoordinates(diffs, false); ShowBorderOnImage(picture, points, fileFolder, name, "horizontal " + mode); PrintBorderPointsToFile(points, mode.ToString(), "horizontal"); //diffs = ImageProcessor.GetDifferenceBeforeOnDirection(bytes, false); //PrintDifferencesTableToFile(diffs, false, mode.ToString(), "horizontal before"); //points = ImageProcessor.GetBorderCoordinates(diffs, false); //ShowBorderOnImage(picture, points, fileFolder, name, "horizontal before" + mode); //PrintBorderPointsToFile(points, mode.ToString(), "horizontal before"); //diffs = ImageProcessor.GetDifferenceAfterOnDirection(bytes, false); //PrintDifferencesTableToFile(diffs, false, mode.ToString(), "horizontal after"); //points = ImageProcessor.GetBorderCoordinates(diffs, false); //ShowBorderOnImage(picture, points, fileFolder, name, "horizontal after" + mode); //PrintBorderPointsToFile(points, mode.ToString(), "horizontal after"); Console.Write("."); } } }