Exemplo n.º 1
0
        private Bitmap CutLeftRight(Bitmap origin, PlateHorizontalGraph graph)
        {
            graph.ApplyProbabilityDistributor(new Graph.ProbabilityDistributor(0f, 0f, 2, 2));
            List <Graph.Peak> peaks = graph.FindPeak(3);

            if (peaks.Count != 0)
            {
                Graph.Peak p = peaks[0];
                return(origin.Clone(new Rectangle(p.Left, 0, p.GetDiff(), Image.Height), PixelFormat.Format8bppIndexed));
            }
            return(origin);
        }
Exemplo n.º 2
0
        private PlateHorizontalGraph HistogramXAxis(Bitmap bitmap)
        {
            PlateHorizontalGraph graph = new PlateHorizontalGraph(this);
            int w = bitmap.Width;
            int h = bitmap.Height;

            for (int x = 0; x < w; x++)
            {
                float counter = 0;
                for (int y = 0; y < h; y++)
                {
                    counter += GetBrightness(bitmap, x, y);
                }
                graph.AddPeak(counter);
            }
            return(graph);
        }
Exemplo n.º 3
0
        public void Normalize()
        {
            Plate clone1 = Clone();

            clone1.VerticalEdgeDetector(clone1.GetBitmap());
            PlateVerticalGraph vertical = clone1.HistogramYaxis(clone1.GetBitmap());

            Image           = CutTopBottom(Image, vertical);
            PlateCopy.Image = CutTopBottom(PlateCopy.Image, vertical);

            Plate clone2 = Clone();

            if (HorizontalDetectionType == 1)
            {
                clone2.HorizontalEdgeDetector(clone2.GetBitmap());
            }
            PlateHorizontalGraph horizontal = clone1.HistogramXAxis(clone2.GetBitmap());

            Image           = CutLeftRight(Image, horizontal);
            PlateCopy.Image = CutLeftRight(PlateCopy.Image, horizontal);
        }