예제 #1
0
        private Bitmap drawDependencyGraph(Bitmap input)
        {
            return MakeBitmap(input.Width, input.Height, (Graphics g) =>
            {
                var polygons = getFilteredPolygons(input);
                MangaParser.Reader.DefaultReadingOrder ro = new MangaParser.Reader.DefaultReadingOrder();

                var graph = DefaultReadingOrder.BuildRelationGraph(polygons.ToList());
                DefaultReadingOrder.SimplifyTransitiveClosure(graph);

                using (Pen p = new Pen(Color.Red, 3)) {
                    g.DrawImageUnscaled(input, 0, 0);

                    foreach (var poly in polygons)
                    {
                        g.DrawRectangle(p, poly.BoundingBox);
                        var origin = poly.CenterOfGravity;

                        foreach (var item in graph[poly])
                        {
                            Color c = item.Item1 == MangaParser.Reader.CellsRelation.BottomOf ?
                                      Color.DarkGreen : Color.Blue;

                            var target = item.Item2.CenterOfGravity;
                            drawArrow(g, c, origin, target);
                        }
                    }
                }
            });
        }
예제 #2
0
        private IEnumerable<TransformedPolygon> getSortedPoly(Bitmap input, ICellsSegmentation segmentation)
        {
            Matrix tsf = Page.ReadingDirectionToMatrix(getReadingDirection());
            var polygons = currentResult.Polygons;
            var tpolys = (from poly in polygons select new TransformedPolygon(poly, tsf));

            MangaParser.Reader.ICellReadingOrder ro = new MangaParser.Reader.DefaultReadingOrder();

            return (from tpoly in ro.GetReadingOrder(tpolys) select (TransformedPolygon)tpoly);
        }