예제 #1
0
        public override void FindBestCuts()
        {
            unchecked
            {
                for (int i = 0; i < cutcosts.Length(); i++)
                {
                    NarrayUtil.ExtPut(dimage, i, (int)(cutcosts[i] + 10), 0xff0000);
                }
                for (int i = 0; i < cutcosts.Length(); i++)
                {
                    NarrayUtil.ExtPut(dimage, i, (int)(min_thresh + 10), 0x800000);
                }
            }
            Floatarray temp = new Floatarray();

            Gauss.Gauss1d(temp, cutcosts, 3.0f);
            cutcosts.Move(temp);
            SegmRoutine.local_minima(ref bestcuts, cutcosts, min_range, min_thresh);
            for (int i = 0; i < bestcuts.Length(); i++)
            {
                Narray <Point> cut = cuts[bestcuts[i]];
                for (int j = 0; j < cut.Length(); j++)
                {
                    Point p = cut[j];
                    NarrayUtil.ExtPut(dimage, p.X, p.Y, 0x00ff00);
                }
            }
            ///-if(debug.Length > 0) write_image_packed(debug, dimage);
            // dshow1d(cutcosts,"Y");
            //dshow(dimage,"Y");
        }
예제 #2
0
        /// <summary>
        /// convenience methods
        /// </summary>
        public virtual void Extract(Floatarray v)
        {
            Floatarray temp = new Floatarray();

            Extract(temp, v);
            v.Move(temp);
        }
예제 #3
0
        /// <summary>
        /// The main loop iteration.
        /// </summary>
        public void Radiate()
        {
            Clear();

            //logger("beam", beam);
            //logger("beamcost", beamcost);

            int control_beam_start = beam.Length();

            for (int i = 0; i < control_beam_start; i++)
            {
                TryAccept(i);
            }

            // in this loop, traversal may add "control nodes" to the beam
            for (int i = 0; i < beam.Length(); i++)
            {
                Traverse(stree.v1[beam[i]], stree.v2[beam[i]],
                         beamcost[i], i);
            }

            // try accepts from control beam nodes
            // (they're not going to the next beam)
            for (int i = control_beam_start; i < beam.Length(); i++)
            {
                TryAccept(i);
            }


            Intarray   new_beam     = new Intarray();
            Floatarray new_beamcost = new Floatarray();

            for (int i = 0; i < nbest.Length(); i++)
            {
                int k = nbest.Tag(i);
                if (parent_trails[k] < 0) // skip the control beam nodes
                {
                    continue;
                }
                new_beam.Push(stree.Add(beam[parent_trails[k]],
                                        all_targets1[k], all_targets2[k],
                                        all_inputs[k], all_outputs[k],
                                        all_costs[k]));
                new_beamcost.Push(beamcost[parent_trails[k]] + all_costs[k]);
                //logger.format("to new beam: trail index %d, stree %d, target %d,%d",
                //k, new_beam[new_beam.length() - 1], all_targets1[k], all_targets2[k]);
            }
            //move(beam, new_beam);
            beam.Move(new_beam);
            //move(beamcost, new_beamcost);
            beamcost.Move(new_beamcost);
        }
예제 #4
0
        public void FindBestCuts()
        {
            /*Intarray segm = new Intarray();
             * segm.Copy(dimage);
             * ImgLabels.simple_recolor(segm);
             * ImgIo.write_image_packed("debug1.png", segm);*/
            unchecked
            {
                for (int i = 0; i < cutcosts.Length(); i++)
                {
                    NarrayUtil.ExtPut(dimage, i, (int)(cutcosts[i] + 10), 0xff0000);
                }
                for (int i = 0; i < cutcosts.Length(); i++)
                {
                    NarrayUtil.ExtPut(dimage, i, (int)(min_thresh + 10), 0x800000);
                }
            }
            Floatarray temp = new Floatarray();

            Gauss.Gauss1d(temp, cutcosts, cost_smooth);
            cutcosts.Move(temp);
            SegmRoutine.local_minima(ref bestcuts, cutcosts, min_range, min_thresh);
            for (int i = 0; i < bestcuts.Length(); i++)
            {
                Narray <Point> cut = cuts[bestcuts[i]];
                for (int j = 0; j < cut.Length(); j++)
                {
                    Point p = cut[j];
                    NarrayUtil.ExtPut(dimage, p.X, p.Y, 0x00ff00);
                }
            }

            /*segm.Copy(dimage);
             * ImgLabels.simple_recolor(segm);
             * ImgIo.write_image_packed("debug2.png", segm);*/
        }
예제 #5
0
 /// <summary>
 /// convenience methods
 /// </summary>
 public virtual void Extract(Floatarray v)
 {
     Floatarray temp = new Floatarray();
     Extract(temp, v);
     v.Move(temp);
 }