public RegionDetector2_0(CanvasARGB canvas)
        {
            this._canvasPixel         = CanvasPixel.CreateBitmpaFromCanvas(canvas);
            this._canvasPixelOriginal = CanvasPixel.CreateBitmpaFromCanvas(canvas);

            this._regionManipulator = new RegionManipulator(this._canvasPixelOriginal, this._canvasPixel);
        }
Esempio n. 2
0
        public CanvasPixel Detect(CanvasARGB canvas, int tolerance)
        {
            _regionPixelLookup = new RegionVO[canvas.Length];
            _listRegion        = new List <RegionVO>();

            CanvasPixel canvasPixel = CanvasPixel.CreateBitmpaFromCanvas(canvas);

            this._regionManipulator = new RegionManipulator(null, canvasPixel);
            //canvasPixel.ConvertPixelsRGBToHSL();
            //canvasPixel.ReduceNotSeenColors();
            //canvasPixel.TransformToInterleaveRGB();

            List <int> singleAlonePoints = CreateRegionFromStart(canvasPixel, 0);// tolerance);

            //List<int> singleAlonePoints = CreateRegionFromStartCicCac(canvasPixel, tolerance);



            FuseAllSinglePoints(singleAlonePoints, canvasPixel, tolerance);

            int minPixels = tolerance;

            //for (int i = 1; i <= 16; i++)
            //    ReduceAllRegionUnderCountPixel(canvasPixel, i);



            for (int i = minPixels;
                 i <= minPixels; i++)
            {
                ReduceAllRegionUnderColorTolerance(canvasPixel, i);
            }
            //ReduceAllRegionUnderCountPixel(canvasPixel, 5);

            Dictionary <int, int> groups = new Dictionary <int, int>();

            foreach (var item in _listRegion)
            {
                if (groups.ContainsKey(item.Pixels.Length))
                {
                    groups[item.Pixels.Length]++;
                }
                else
                {
                    groups.Add(item.Pixels.Length, 1);
                }
            }



            //canvasPixel.ConvertPixelsHSLToRGB();
            return(canvasPixel);
        }
Esempio n. 3
0
        public void AreasToSVG(CanvasPixel original, List <RegionVO> regions, RegionManipulator regMan)
        {
            Write_StartHeader(original.Width, original.Height);

            RegionVO[] regionsOrdered = regMan.GetOrderedForRendering(regions.ToArray());

            RegionToPolygonBO regionToPolygon = new RegionToPolygonBO(regMan);

            for (int i = 0; i < regionsOrdered.Length; i++)
            {
                RegionVO region = regionsOrdered[i];

                Point[] points = regionToPolygon.ToPolygon(region);

                _output.WriteLine(Helper_CreateSVGPolyLine(points, region.Color));
                // _output.WriteLine(Helper_CreateSVGPolyGone(points, region.Color));
            }


            Write_EndHeader();
        }
Esempio n. 4
0
 public RegionEdgeCrawler(RegionVO region, RegionManipulator rm)
 {
     this._regionManipulator = rm;
     this._pixels            = new HashSet <int>(region.Pixels);
 }
Esempio n. 5
0
 public RegionToPolygonBO(RegionManipulator regionManipulator)
 {
     this._regionManipulator = regionManipulator;
 }