public Cluster(point CentroidCoordinates,int []color)
 {
     this.p.x = CentroidCoordinates.x;
     this.p.y = CentroidCoordinates.y;
     this.color[0] = color[0];
     this.color[1] = color[1];
     this.color[2] = color[2];
 }
 bool isFound(List<Cluster> pool, point val)
 {
     for (int i = 0; i < pool.Count; i++)
     {
         if (pool[i].p.x == val.x && pool[i].p.y == val.y)
             return true;
     }
     return false;
 }
 int calculateDistance(point p, point c)
 {
     double d = Math.Sqrt(Math.Pow((p.x - c.x), 2) + Math.Pow((p.y - c.y), 2));
     return Convert.ToInt32(d);
 }
        // calculate mean to generate new centroid
        point calculateMean(List<point> p)
        {
            point tmpPoint = new point();
            int sumX = 0, sumY = 0;
            for (int i = 0; i < p.Count; i++)
            {
                sumX += p[i].x;
                sumY += p[i].y;
            }

            if (p.Count != 0)
            {
                tmpPoint.x = sumX / p.Count;
                tmpPoint.y = sumY / p.Count;

            }
            else
            {
                tmpPoint.x = 0;
                tmpPoint.y = 0;
            }

            return tmpPoint;
        }