I am having a hard time understanding what scipy.cluster.vq really does!!
On Wikipedia it says Clustering can be used to divide a digital image into distinct regions for border detection or object recognition.
on other sites and books it says we can use clustering methods for clustering images for finding groups of similar images.
AS i am interested in image processing ,I really need to fully understand what clustering is .
So
Can anyone show me simple examples about using scipy.cluster.vq with images??
The kind of clustering performed by
scipy.cluster.vqis definitely of the latter (groups of similar images) variety.The only clustering algorithm implemented in
scipy.cluster.vqis the K-Means algorithm, which typically treats input data as points in n-dimensional euclidean space, and attempts to divide that space so that new, incoming data can be summarized by saying “example x is most like centroid y”. Centroids can be thought of as prototypical examples of the input data. Vector quantization leads to concise, or compressed representations because, instead of remembering all 100 pixels of each new image we see, we can remember a single integer which points at the prototypical example that the new image is most like.If you had many small grayscale images:
So, we’ve got 100 10×10 pixel images. Let’s assume they already all have similar brightness and contrast. The scipy kmeans implementation expects flat vectors:
Now, let’s train the K-Means algorithm so that any new incoming image can be assigned to one of 10 clusters:
Finally, let’s say we have five new images we’d like to assign to one of the ten clusters:
clusterswill contain the integer index of the best matching centroid for each of the five examples.This is kind of a toy example, and won’t yield great results unless the objects of interest in the images you’re working with are all centered. Since objects of interest might appear anywhere in larger images, it’s typical to learn centroids for smaller image “patches”, and then convolve them (compare them at many different locations) with larger images to promote translation-invariance.