Пример #1
0
        /// <summary>
        /// Classifies every pixel in the provided image, returning a full distribution over all labels.
        /// </summary>
        /// <param name="forest">The forest used for the computation</param>
        /// <param name="image">Image to classify</param>
        /// <returns>The classified image</returns>
        public static DistributionImage ClassifySoft <T>(this DecisionForest <ImageDataPoint <T>, T[]> forest, LabeledImage <T> image)
        {
            DistributionImage dist = new DistributionImage(image.Image.Rows, image.Image.Columns, forest.LabelCount);

            dist.ID = image.ID;
            for (int t = 0; t < forest.TreeCount; t++)
            {
                forest[t].ClassifySoft(image, dist);
            }
            dist.DivideThrough(forest.TreeCount);
            dist.Normalize();
            return(dist);
        }
Пример #2
0
        /// <summary>
        /// Computes a label distribution at each pixel by combining its node distributions.
        /// </summary>
        /// <returns>Distribution image</returns>
        public DistributionImage ComputeDistributionImage()
        {
            DistributionImage dist = new DistributionImage(_rows, _columns, _data[0, 0, 0].Distribution.Length);

            dist.ID = ID;
            for (int r = 0; r < _rows; r++)
            {
                for (int c = 0; c < _columns; c++)
                {
                    for (int t = 0; t < _trees; t++)
                    {
                        dist.Add(r, c, _data[r, c, t].Distribution);
                    }
                }
            }
            dist.DivideThrough(_trees);
            dist.Normalize();
            return(dist);
        }