public void TestCellsOrdering() { ICellsSegmentation segmenter = new AFThresholdBlobSegmentation(); //Load the test data var testColors = new List<Color>(loader.TestColors); foreach (var test in loader.Tests) { IExtractionResult result; using (Bitmap input = test.GetBitmap(DataLoader.TestDirectoryInput)) using (Bitmap polyColors = test.GetBitmap(DataLoader.TestDirectoryAny)) { result = segmenter.Extract(input); //Left to right, top to bottom reading order. Other orders can // be obtained through polygon transformations, outside of the // scope of this test. ICellReadingOrder readingOrder = new DefaultReadingOrder(); List<Color> outputSequence = new List<Color>( from polygon in readingOrder.GetReadingOrder(result.Polygons) let point = polygon.Points.First() select polyColors.GetPixel(point.X, point.Y)); if (outputSequence.Count > testColors.Count) throw new FormatException("Wrong test"); for (int i = 0; i < outputSequence.Count; i++) { Assert.AreEqual(testColors[i], outputSequence[i]); } } } }
public void TestSegmenterRequiredPoints() { ICellsSegmentation segmenter = new AFThresholdBlobSegmentation(); //Load the test data var testColors = new HashSet<Color>(loader.TestColors); foreach (var test in loader.Tests) { IExtractionResult result; using (Bitmap input = test.GetBitmap(DataLoader.TestDirectoryInput)) using (Bitmap expected = test.GetBitmap(DataLoader.TestDirectoryAll)) { result = segmenter.Extract(input); CheckAllExpected(expected, result, testColors); } } }
private IEnumerable<TransformedPolygon> getSortedPoly(Bitmap input) { AFThresholdBlobSegmentation extractor = new AFThresholdBlobSegmentation(); return getSortedPoly(input, extractor); }
private void updatePicture() { Bitmap b = getOriginalPicture(); AFThresholdBlobSegmentation extractor = new AFThresholdBlobSegmentation(getThresholdValue()); currentResult = (AFThresholdBlobSegmentation.AFThresholdBlobSegmentationResult) extractor.Extract(b); label1.Text = ""; if (currentResult.FullPage) { label1.Text = "Full page; "; } if (currentResult.InvertedBorders) { label1.Text += "Inverted"; } foreach (var transform in transforms) { b = transform(b); } pictureBox2.Image = b; }
private Bitmap drawFilteredHulls(Bitmap input) { AFThresholdBlobSegmentation extractor = new AFThresholdBlobSegmentation(); return MakeBitmap(input.Width, input.Height, (Graphics g) => { IEnumerable<Polygon> polygons = getFilteredPolygons(input); using (Pen p = new Pen(Color.Red, 3)) { g.DrawImageUnscaled(input, 0, 0); foreach (var poly in polygons) { g.DrawPolygon(p, poly.Points.ToArray()); } } }); }