예제 #1
0
 /// <summary>
 /// Delete Edges with Max Weight And Remove THis Edges from the mstdictionary
 /// </summary>
 /// <param name="K">Number of Desired Clusters</param>
 void Extract_KClusters(int k)
 {
     //⊖(k*log D)
     for (int j = 0; j < k - 1; j++)
     {
         Edge edgeHolder = edgesHeap.getMaxEdge();                  //⊖(log E)
         adjDictArray[edgeHolder.colorA].Remove(edgeHolder.colorB); //⊖(1)
         adjDictArray[edgeHolder.colorB].Remove(edgeHolder.colorA); //⊖(1)
     }
 }
예제 #2
0
        public RGBPixel[,,] autoClustring(int k, List <RGBPixelD> listRGB, int size)
        {
            int q = 1;                                                          //⊖(1)

            MSTDictionaryCur = MSTDictionary;                                   //⊖(1)
            MSTDictionary    = prim(size, listRGB);                             //⊖(D log E)
            while (!maxHeap.isEmpty())                                          //⊖(E log E)
            {
                Edge edgeHolder = maxHeap.top();                                //⊖(1)
                if (edgeHolder.weight > (Mean + STDev))                         //⊖(1)
                {
                    maxHeap.getMaxEdge();                                       //⊖(log E)
                    q++;                                                        //⊖(1)
                    MSTDictionary[edgeHolder.colorA].Remove(edgeHolder.colorB); //⊖(1)
                    MSTDictionary[edgeHolder.colorB].Remove(edgeHolder.colorA); //⊖(1)
                }
                else
                {
                    break;  //⊖(1)
                }
            }

            if (q <= k)                                                         //⊖(1)=*body(⊖(K log E))
            {
                for (int j = q; j < k; j++)                                     //⊖(k)* body(⊖(log E))
                {
                    Edge edgeHolder = maxHeap.getMaxEdge();                     //⊖(log E)
                    MSTDictionary[edgeHolder.colorA].Remove(edgeHolder.colorB); //⊖(1)
                    MSTDictionary[edgeHolder.colorB].Remove(edgeHolder.colorA); //⊖(1)
                }
                FindRepresentativeColors(size);                                 //⊖(D)
                return(replacedMatrix);                                         //⊖(1)
            }
            else // O(D * size of new list)
            {
                FindRepresentativeColors(size);              //⊖(D)
                rGBPixels = autoClustring(k, newListRGB, q); // O(D * size of new list)+//⊖(E log E)??????
                fillColors(listRGB.Count);                   // O(D * size of new list)
            }
            return(replacedMatrix);                          //⊖(1)
        }