Exemplo n.º 1
0
        private PlateHorizontalGraph HistogramXaxis(IplImage image)
        {
            PlateHorizontalGraph graph     = new PlateHorizontalGraph(this);
            IplImage             imageCopy = null;

            Int32 w = image.Width;
            Int32 h = image.Height;

            try
            {
                imageCopy = new IplImage(image.Size, image.Depth, image.NChannels);
                Cv.CvtColor(image, imageCopy, ColorConversion.RgbToHsv);

                for (Int32 x = 0; x < w; x++)
                {
                    Double counter = 0;
                    for (Int32 y = 0; y < h; y++)
                    {
                        counter += GetBrightness(imageCopy, x, y);
                    }
                    graph.AddPeak(counter);
                }
            }
            finally
            {
                if (null != imageCopy)
                {
                    Cv.ReleaseImage(imageCopy);
                }
            }

            return(graph);
        }
Exemplo n.º 2
0
        private IplImage CutLeftRight(IplImage origin, PlateHorizontalGraph graph, Int32 method)
        {
            graph.ApplyProbabilityDistributor(new Graph.ProbabilityDistributor(0.0, 0.0, 2, 2));
            List <Graph.Peak> peaks = graph.FindPeak(3, method);

            if (peaks.Count != 0)
            {
                Graph.Peak p = peaks[0];
                return(GetSubImage(origin, new CvRect(p.Left, 0, p.GetDiff, image.Height)));
            }
            else
            {
                return(origin.Clone());
            }
        }
Exemplo n.º 3
0
        public void Normalize(Int32 method)
        {
            IplImage tempImage = null;
            Plate    clone1    = this.Clone();

            VerticalEdgeDetector(clone1.GetImage);
            //clone1.GetImage.SaveImage(@"C:\temp\newImages\newVerticalEdgeDetector.png");
            PlateVerticalGraph vertical = clone1.HistogramYaxis(clone1.GetImage);

            tempImage = CutTopBottom(image, vertical);
            Cv.ReleaseImage(image);
            image = tempImage;
            // JIVAN
            //plateCopy.image.SaveImage(@"C:\temp\newImages\newBEFOREVerticalCutTopBottom.png");
            tempImage = CutTopBottom(plateCopy.image, vertical);
            Cv.ReleaseImage(plateCopy.image);
            plateCopy.image = tempImage;
            // JIVAN
            //plateCopy.image.SaveImage(@"C:\temp\newImages\newVerticalCutTopBottom.png");
            Plate clone2 = this.Clone();

            if (1 == horizontalDetectionType)
            {
                HorizontalEdgeDetector(clone2.GetImage);
                //TODO JIVAN Remove these 2 lines when project gest done
                //clone2.ClearImage();
                //clone2 = new Plate(new IplImage(@"C:\temp\HorizontalEdgeDetector.png"));
                //clone2.GetImage.SaveImage(@"C:\temp\newImages\newCloneHorizontalEdgeDetector.png");
            }

            PlateHorizontalGraph horizontal = clone1.HistogramXaxis(clone2.GetImage);

            tempImage = CutLeftRight(image, horizontal, method);
            Cv.ReleaseImage(image);
            image     = tempImage;
            tempImage = CutLeftRight(plateCopy.image, horizontal, method);
            Cv.ReleaseImage(plateCopy.image);
            plateCopy.image = tempImage;
            // JIVAN
            //plateCopy.image.SaveImage(@"C:\temp\newImages\newHorizontalCutLeftRight.png");

            clone2.ClearImage();
            clone1.ClearImage();
        }