where K is the number of subsets, Cj is the subsets, J is the global minimum, jdy ljj is a distance measure between the contextual feature vector dy representing the yth pixel and lj, which is the mean value of subset Cj. The procedure starts with the random assignment of K subsets, followed by an alternating phase of assigning dy to the closest subset and calculating new means for the subsets(when dy is included in the subset change, the mean changes).The procedure stops when there are no more dy changes in the subsets(Weisstein, 2014).