Exemplo n.º 1
0
        public static double GetDistance(Sign el1, Sign el2)
        {
            int sf2 = (el2.SignForm - el1.SignForm) * (el2.SignForm - el1.SignForm);
            double rc2 = Math.Pow(el2.RedColor - el1.RedColor, 2);
            double bc2 = Math.Pow(el2.BlueColor - el1.BlueColor, 2);
            double whc2 = Math.Pow(el2.WhiteColor - el1.WhiteColor, 2);
            double yc2 = Math.Pow(el2.YellowColor - el1.YellowColor, 2);

            return Math.Sqrt(sf2 + rc2 + bc2 + whc2 + yc2);
        }
 public int ClassifyElement(Sign sign)
 {
     double min = double.MaxValue;
     Cluster cluster = ClusterList[0];
     foreach (Cluster s in ClusterList)
     {
         double dist = s.GetDistanceToCenter(sign);
         if (dist <= min)
         {
             min = dist;
             cluster = s;
         }
     }
     return cluster.Number;
 }
 public int FindClass(Sign sign)
 {
     return(_classifier.ClassifyElement(sign));
 }
 public double GetDistanceToCenter(Sign element)
 {
     return(Sign.GetDistance(Center, element));
 }
 public Cluster(Sign center, int number)
 {
     Center      = center;
     ElementList = new List <Sign>();
     Number      = number;
 }
 public int FindClass(Sign sign)
 {
     return _classifier.ClassifyElement(sign);
 }