Number of classes is usually given as an input variable. We have chosen 16 because it is a power of 2, and about the size that a human can visualize easily (more than 16 and the image starts to look cluttered).
There are sometimes good reasons to use a specific number of classes. You may be wanting to classify a scene into vegetation, soil and water, in which case 3 or 4 should suffice.
Or, you may want to display a 4 Million color image on a 256 color terminal. So you would cluster with 256 classes to do the mapping. Of course, color histogramming may be a more efficient way to do this. Clustering has the additional problem that some classes may drop out (see Dead classes ).