Ejemplo n.º 1
0
        /// <summary>
        /// Classifies points from <paramref name="labeledImage"/> (using the mask if present) and adds the distributions at each pixel to <paramref name="dist"/>.
        /// </summary>
        /// <param name="tree">The tree used for the computation</param>
        /// <param name="labeledImage">The image to classify</param>
        /// <param name="dist">Image which is used to store the distributions</param>
        public static void ClassifySoft <T>(this DecisionTree <ImageDataPoint <T>, T[]> tree, LabeledImage <T> labeledImage, DistributionImage dist)
        {
            List <ImageDataPoint <T> > points = labeledImage.CreateAllDataPoints(BackgroundSampleMode.Full);
            List <int> indices = new List <int>();

            for (int i = 0; i < points.Count; i++)
            {
                indices.Add(i);
            }
            INodeInfo <ImageDataPoint <T>, T[]>[] info = new INodeInfo <ImageDataPoint <T>, T[]> [points.Count];
            DecisionTree <ImageDataPoint <T>, T[]> .assignLabels(tree._root, points, info, indices);

            for (int i = 0; i < info.Length; i++)
            {
                dist.Add(points[i].Row, points[i].Column, info[i].Distribution);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Classifies each point from <paramref name="image"/> and trackes which nodes it visits.
        /// </summary>
        /// <param name="tree">The tree used for the computation</param>
        /// <param name="image">Image to add to the tree</param>
        /// <param name="mode">Mode to use when sampling the image</param>
        public static void Fill <T>(this DecisionTree <ImageDataPoint <T>, T[]> tree, LabeledImage <T> image, BackgroundSampleMode mode)
        {
            List <ImageDataPoint <T> > points = image.CreateAllDataPoints(mode);

            tree.Fill(points);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Computes a histogram for all trees from the provided image.
 /// </summary>
 /// <param name="forest">The forest used for the computation</param>
 /// <param name="image">Image to classify</param>
 /// <returns>The histogram</returns>
 public static TreeHistogram ComputeHistogram <T>(this DecisionForest <ImageDataPoint <T>, T[]> forest, LabeledImage <T> image)
 {
     return(forest.ComputeHistogram(image.CreateAllDataPoints(BackgroundSampleMode.Full)));
 }