/// <summary> /// Classifies <paramref name="image"/>, creating a distribution over all labels at each pixel. /// </summary> /// <param name="tree">The tree used for the computation</param> /// <param name="image">Image to classify</param> /// <returns>Distributions at each pixel</returns> public static DistributionImage ClassifySoft <T>(this DecisionTree <ImageDataPoint <T>, T[]> tree, IMultichannelImage <T> image) { DistributionImage dist = new DistributionImage(image.Rows, image.Columns, tree.LabelCount); tree.ClassifySoft(image, dist); dist.Normalize(); return(dist); }
/// <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); }
/// <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); }