Esempio n. 1
0
        public void update(MouseEventArgs e)
        {
            var g = pictureBox1.CreateGraphics();

            if (clr > W8interval * 2)
            {
                if (ImageMatrix != null)
                {
                    var mouseNode = Helper.Flatten(e.X, e.Y, ImageOperations.GetWidth(ImageMatrix));

                    if (curr_source != -1 && Prev_mouse_pos != mouseNode)
                    {
                        Prev_mouse_pos = mouseNode;
                        if (Helper.IN_Boundary(mouseNode, SB, ImageOperations.GetWidth(ImageMatrix)))
                        {
                            int Segment_mouse = Helper.crosspond(mouseNode, SB,
                                                                 ImageOperations.GetWidth(ImageMatrix), ImageOperations.GetWidth(Square_segment));
                            List <Point> segmentpath = new List <Point>();
                            segmentpath = ShortestPath_Operations.Backtracking(parent_list, Segment_mouse, ImageOperations.GetWidth(Square_segment));
                            List <Point> Curpath = Helper.crosspond(segmentpath, SB);
                            curr_path = Curpath.ToArray();
                            if (AutoAnchor_WORK)
                            {
                                double freq = (double)frequancy / 1000;
                                Autoancor.Update(Curpath, freq);
                                List <Point> cooledpath = Autoancor.anchor_path();
                                if (cooledpath.Count > 0)
                                {
                                    Point anchor = cooledpath[cooledpath.Count - 1];
                                    AnchorPts.Add(anchor);
                                    curr_source = Helper.Flatten(anchor.X, anchor.Y, ImageOperations.GetWidth(ImageMatrix));
                                    //curr_path = cooledpath.ToArray();
                                    Helper.AppendToList <Point>(Mainselction, cooledpath);
                                    SB = new Boundary();
                                    SB = ShortestPath_Operations.Square_Boundary(curr_source,
                                                                                 ImageOperations.GetWidth(ImageMatrix) - 1, ImageOperations.GetHeight(ImageMatrix) - 1);
                                    //make a square segment
                                    Square_segment = Helper.COPY_Segment(ImageMatrix, SB);
                                    // currsrc in segment
                                    int newsrc = Helper.crosspond(curr_source, SB, ImageOperations.GetWidth(ImageMatrix), ImageOperations.GetWidth(Square_segment));
                                    parent_list = ShortestPath_Operations.Dijkstra(newsrc, Square_segment);
                                    Autoancor.reset();
                                }
                            }
                        }
                        else
                        {
                            curr_path = ShortestPath_Operations.GenerateShortestPath(curr_source, mouseNode, ImageMatrix).ToArray();
                        }
                    }
                }
                clr = 0.0f;
            }
            if (clr > W8interval)
            {
                pictureBox1.Refresh();
                g.Dispose();
            }
            clr += .019f;
        }
Esempio n. 2
0
 private void crop_Click(object sender, EventArgs e)
 {
     if (curr_source != main_source)
     {
         // check if first node in shortest path range of last node
         //if yes get it fast else try to get it by dikstra
         if (Helper.IN_Boundary(main_source, SB, ImageOperations.GetWidth(ImageMatrix)))
         {
             int          Segment_mouse = Helper.crosspond(main_source, SB, ImageOperations.GetWidth(ImageMatrix), ImageOperations.GetWidth(Square_segment));
             List <Point> segmentpath   = new List <Point>();
             segmentpath = ShortestPath_Operations.Backtracking(parent_list, Segment_mouse, ImageOperations.GetWidth(Square_segment));
             curr_path   = Helper.crosspond(segmentpath, SB).ToArray();
         }
         else
         {
             curr_path = ShortestPath_Operations.GenerateShortestPath(curr_source, main_source, ImageMatrix).ToArray();
         }
         Helper.AppendToList <Point>(Mainselction, curr_path);
         //flod fill and crop
         RGBPixel[,] selected_image = floodfill.fill(Mainselction, ImageMatrix);
         CropedImage CI = new CropedImage(selected_image);
         CI.Show();
         reset();
     }
 }