Exemplo n.º 1
0
        private void DirectionToFile_Click(object sender, RoutedEventArgs e)
        {
            if (_currentImage == null)
            {
                return;
            }

            Stopwatch performanceCounter = new Stopwatch();

            performanceCounter.Start();

            CanvasARGB  canvas      = Get_ProgressOrOrigInput();
            CanvasPixel canvasPixel = CanvasPixel.CreateBitmpaFromCanvas(canvas);

            CanvasEdgeVO canvasEdges = CanvasEdgeVO.CreateEdgesFromCanvas(canvasPixel);

            EdgeDetector.EdgeReducer(canvasEdges, 255);

            EdgesWriteToFile(canvasEdges, "directions3.txt");

            CanvasPixel evisualise = VisualiseDetectedEdges(canvasEdges);

            _lastImage = CanvasPixel.CreateBitmpaFromCanvas(evisualise);



            performanceCounter.Stop();

            Helper_SetAppTitle(string.Format("{0,000} s ", performanceCounter.Elapsed.TotalSeconds));

            ShowImage(false);
        }
Exemplo n.º 2
0
        private void Button_Click_41(object sender, RoutedEventArgs e)
        {
            if (_currentImage == null)
            {
                return;
            }

            int inputNumber = int.Parse(NumberInput.Text);

            Stopwatch performanceCounter = new Stopwatch();

            performanceCounter.Start();

            CanvasARGB canvas = Get_ProgressOrOrigInput();

            CanvasPixel tmpCanvasPixel = CanvasPixel.CreateBitmpaFromCanvas(canvas);

            ColorReductor cr = new ColorReductor();

            cr.ReduceByMask(tmpCanvasPixel, inputNumber);


            _lastImage = CanvasPixel.CreateBitmpaFromCanvas(tmpCanvasPixel);

            performanceCounter.Stop();

            Helper_SetAppTitle(string.Format("{0,000} s    ", performanceCounter.Elapsed.TotalSeconds));

            ShowImage(false);
        }
Exemplo n.º 3
0
        private void CollorToGray_Click(object sender, RoutedEventArgs e)
        {
            if (_currentImage == null)
            {
                return;
            }

            int inputNumber = int.Parse(NumberInput.Text);

            Stopwatch performanceCounter = new Stopwatch();

            performanceCounter.Start();

            CanvasARGB  canvas      = Get_ProgressOrOrigInput();
            CanvasPixel canvasPixel = CanvasPixel.CreateBitmpaFromCanvas(canvas);

            ColorToGrey ctg = new ColorToGrey();

            Array2D matrix = ctg.CreateColloredMatrix(canvasPixel.Width, canvasPixel.Height, inputNumber);

            CanvasPixel resultCanvas = ctg.CreateColoredGreyScale(canvasPixel, matrix);



            _lastImage = CanvasPixel.CreateBitmpaFromCanvas(resultCanvas);



            performanceCounter.Stop();

            Helper_SetAppTitle(string.Format("{0,000} s ", performanceCounter.Elapsed.TotalSeconds));

            ShowImage(false);
        }
Exemplo n.º 4
0
        private void Button_Click_3(object sender, RoutedEventArgs e)
        {
            if (_currentImage == null)
            {
                return;
            }

            int inputNumber = int.Parse(NumberInput.Text);

            Stopwatch performanceCounter = new Stopwatch();

            performanceCounter.Start();

            CanvasARGB canvas = Get_ProgressOrOrigInput();

            RegionDetektor rd = new RegionDetektor();
            CanvasPixel    cp = rd.DetectOld(canvas, inputNumber);

            //cp.TransformFromInterleaveRGB();

            _lastImage = CanvasPixel.CreateBitmpaFromCanvas(cp);

            performanceCounter.Stop();

            Helper_SetAppTitle(string.Format("{0,000} s    - regions : {1}", performanceCounter.Elapsed.TotalSeconds, rd.TotalRegions));

            ShowImage(false);
        }
Exemplo n.º 5
0
        public RegionDetector2_0(CanvasARGB canvas)
        {
            this._canvasPixel         = CanvasPixel.CreateBitmpaFromCanvas(canvas);
            this._canvasPixelOriginal = CanvasPixel.CreateBitmpaFromCanvas(canvas);

            this._regionManipulator = new RegionManipulator(this._canvasPixelOriginal, this._canvasPixel);
        }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
0
        private void TraceNew_Click_1(object sender, RoutedEventArgs e)
        {
            if (_currentImage == null)
            {
                return;
            }


            int inputNumber = int.Parse(NumberInput.Text);

            Stopwatch performanceCounter = new Stopwatch();

            performanceCounter.Start();

            CanvasARGB canvas = Get_ProgressOrOrigInput();


            CanvasPixel tmpCanvasPixel = CanvasPixel.CreateBitmpaFromCanvas(canvas);

            canvas = CanvasPixel.CreateBitmpaFromCanvas(tmpCanvasPixel);

            RegionDetector2_0 rd = new RegionDetector2_0(canvas);

            rd.Detect_ByColorToleranceNew(inputNumber);
            CanvasPixel cp = rd.Get_CanvasFromRegions();

            if (CheckSaveToSVG.IsChecked.Value)
            {
                rd.ConvertRegionsToSVG(Helper_GetFileName_ForSVG(this._currentOpenFilename));
            }

            // cp.TransformFromInterleaveRGB();

            _lastImage = CanvasPixel.CreateBitmpaFromCanvas(cp);

            VectorPreview window = new VectorPreview();

            //window.RenderLines( tmpCanvasPixel,cp);

            window.RenderPolygons(rd.Regions, rd.RegionManipulator);
            window.Show();

            performanceCounter.Stop();

            Helper_SetAppTitle(string.Format("{0,000} s    - regions : {1}", performanceCounter.Elapsed.TotalSeconds, rd.TotalRegions));

            ShowImage(false);
        }
Exemplo n.º 8
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (_currentImage == null)
            {
                return;
            }


            int inputNumber = int.Parse(NumberInput.Text);

            Stopwatch performanceCounter = new Stopwatch();

            performanceCounter.Start();

            CanvasARGB canvas = Get_ProgressOrOrigInput();
            //for (int i = 0; i < 28000; i += 4)
            //{
            //    canvas.Data[i] = 0;
            //    canvas.Data[i + 1] = 255;
            //    canvas.Data[i + 2] = 0;
            //    canvas.Data[i + 3] = 255;
            //}


            CanvasPixel canvasPixel = CanvasPixel.CreateBitmpaFromCanvas(canvas);

            canvasPixel.TransformToInterleaveRGB();
            BasicOperation.PixelFilter2(canvasPixel, inputNumber);
            //canvasPixel.
            //BasicOperation.BlackWhite(canvasPixel);

            _lastImage = CanvasPixel.CreateBitmpaFromCanvas(canvasPixel);



            //BitmapSource bs = CanvasARGB.CreateBitmpaFromCanvas(canvas);

            //_originalImage = bs;
            //byte [] array = BitmapToArray(_originalImage);

            performanceCounter.Stop();

            Helper_SetAppTitle(string.Format("{0,000} s", performanceCounter.Elapsed.TotalSeconds));

            ShowImage(false);
            //RenderTargetBitmap.Create( rtb
            //textBox1.Text = ofd.FileName;
        }