Example #1
0
 /// <summary>
 /// Relabels all datasets using a label mapping collection.
 /// </summary>
 /// <param name="col">Specifies the label mapping collection.</param>
 public void Relabel(LabelMappingCollection col)
 {
     foreach (DatasetEx ds in m_rgDatasets)
     {
         ds.Relabel(col);
     }
 }
Example #2
0
        /// <summary>
        /// Reset the image set based on the LabelMappingCollection.
        /// </summary>
        /// <param name="col">Specifies the label mapping that defines how to relabel the image set.</param>
        /// <returns>The new list of DbItem's is returned based on the newly updated labels.</returns>
        public List <DbItem> Relabel(LabelMappingCollection col)
        {
            List <DbItem> rgItems = m_masterList.Relabel(col);

            m_masterIdx.Reload(rgItems);
            return(rgItems);
        }
Example #3
0
        /// <summary>
        /// Applies the label mapping to the image set.
        /// </summary>
        /// <param name="col"></param>
        public void Relabel(LabelMappingCollection col)
        {
            foreach (SimpleDatum sd in m_rgImages)
            {
                sd.SetLabel(col.MapLabel(sd.OriginalLabel));
            }

            ReloadLabelSets();
        }
Example #4
0
        /// <summary>
        /// Relabels both the testing and training image sets using the label mapping collection.
        /// </summary>
        /// <param name="col">Specifies the label mapping collection.</param>
        public void Relabel(LabelMappingCollection col)
        {
            List <DbItem> rgItems = m_TrainingImages.Relabel(col);

            m_queryStates.ReIndexTraining(rgItems);

            rgItems = m_TrainingImages.Relabel(col);
            m_queryStates.ReIndexTesting(rgItems);
        }
Example #5
0
        /// <summary>
        /// Returns a copy of the label mapping collection.
        /// </summary>
        /// <returns></returns>
        public LabelMappingCollection Clone()
        {
            LabelMappingCollection col = new LabelMappingCollection();

            foreach (LabelMapping m in m_rgMappings)
            {
                col.Add(m.Clone());
            }

            return(col);
        }
Example #6
0
        /// <summary>
        /// Compares one label mapping collection to another.
        /// </summary>
        /// <param name="col">Specifies the other collection to compare.</param>
        /// <returns>If the two collections are the same, <i>true</i> is returned, otherwise <i>false</i> is returned.</returns>
        public bool Compare(LabelMappingCollection col)
        {
            Sort();
            col.Sort();

            string strA = ToString();
            string strB = col.ToString();

            if (strA == strB)
            {
                return(true);
            }

            return(false);
        }
Example #7
0
        /// <summary>
        /// Relabel the images based on the LabelMappingCollection.
        /// </summary>
        /// <param name="col">Specifies the label mapping collection.</param>
        /// <returns>The new set of DBItems is returned for the images.</returns>
        public List <DbItem> Relabel(LabelMappingCollection col)
        {
            if (!IsFull)
            {
                throw new Exception("Relabeling only supported on fully loaded data sets.");
            }

            foreach (SimpleDatum sd in m_rgImages)
            {
                if (sd != null)
                {
                    sd.SetLabel(col.MapLabelWithoutBoost(sd.OriginalLabel));
                }
            }

            return(ReloadIndexing());
        }
Example #8
0
 /// <summary>
 /// Relabels both the testing and training image sets using the label mapping collection.
 /// </summary>
 /// <param name="col">Specifies the label mapping collection.</param>
 public void Relabel(LabelMappingCollection col)
 {
     m_TestingImages.Relabel(col);
     m_TrainingImages.Relabel(col);
 }
Example #9
0
        /// <summary>
        /// Parses a list of strings where each string is a label mapping.
        /// </summary>
        /// <param name="rgstrMappings">Specifies the list of label mapping strings.</param>
        /// <returns>The new LabelMappingCollection is returned.</returns>
        public static LabelMappingCollection Parse(List <string> rgstrMappings)
        {
            LabelMappingCollection col             = new LabelMappingCollection();
            List <string>          rgstrSeparators = new List <string>()
            {
                "->"
            };

            foreach (string strMapping in rgstrMappings)
            {
                string[] rgstr = strMapping.Split(rgstrSeparators.ToArray(), StringSplitOptions.RemoveEmptyEntries);

                if (rgstr.Length != 2)
                {
                    throw new Exception("Each label mapping should have the format 'original->new_label'.");
                }

                if (rgstr[0].Length == 0 || rgstr[1].Length == 0)
                {
                    throw new Exception("Each label mapping should have the format 'original->new_label'.");
                }

                string str1 = rgstr[0].Trim('\"');
                string str2 = rgstr[1].Trim('\"');
                int?   nConditionBoostEquals = null;
                int?   nConditionFalse       = null;

                rgstr = str2.Split('?');
                if (rgstr.Length > 1)
                {
                    str2 = rgstr[0].Trim();

                    string strCondition = "";
                    string strRightSide = rgstr[1].Trim();
                    rgstr = strRightSide.Split(',');

                    if (rgstr.Length == 2)
                    {
                        string str3 = rgstr[0].Trim();
                        if (str3.Length > 0)
                        {
                            nConditionFalse = int.Parse(str3);
                        }

                        strCondition = rgstr[1].Trim();
                    }
                    else if (rgstr.Length == 1)
                    {
                        strCondition = rgstr[0].Trim();
                    }
                    else
                    {
                        throw new Exception("Invalid mapping format! Expected format <true_int>?<false_int>,boost=<int>");
                    }

                    rgstr = strCondition.Split('=');

                    if (rgstr.Length != 2 || rgstr[0].Trim().ToLower() != "boost")
                    {
                        throw new Exception("Invalid boost condition!  Expected format = ?boost=<int>");
                    }

                    nConditionBoostEquals = int.Parse(rgstr[1].Trim());
                }

                col.Add(new LabelMapping(int.Parse(str1), int.Parse(str2), nConditionBoostEquals, nConditionFalse));
            }

            return(col);
        }