I am new to the Machine Learning area and I have a question to ask. But let me first post the problem.

Problem: The problem is very simple. I want to classify images as Category-1("Images containing garbage") or Category-2("Images not containing garbage"). Garbage is used in every literal sense of the word.

Solution I opted for: The solution also happens to be pretty straightforward for the most part. Extract points of interest using an Algorithm like SIFT,SURF etc etc. Then obtain the descriptors of these key points and cluster them using the K-means algorithm. Then using this clustered data generate the bag of words and proceed from there.

The thing which I am unable to comprehend is the number of clusters which I might need. Any help with the above example would be much appreciated.

  • 1
    $\begingroup$ What are you clustering exactly ? Regions of interest ? $\endgroup$ Dec 26, 2016 at 16:31
  • $\begingroup$ Cluster the descriptors. Basically yeah, the regions of interest. $\endgroup$ Dec 28, 2016 at 5:46
  • $\begingroup$ If your descriptor is a pixel and what you want is the region that gives garbage, you can use region growing methods. If you had already done this, and you want to cluster regions, why are not able to decide clusters by Silhouette method. Just curious to know why. $\endgroup$ Dec 28, 2016 at 6:22

3 Answers 3


Measure, don't guess

It appears to be common to try k=1024, 2048, 4096, ... and use what works best for classification.

This is possivle because the clustering is actually a quantization task, and you do classification afterwards.


Why go for something so complicated? You can do it quite simply with a big enough dataset using convolutional neural network. There are tons of material available discussing the use of CNNs to image classification, MNIST digit recognition. Hope this helps. You can use PIL to extract pixel values. Though you will need labelled data.


Build classifier using a deep learning algorithm called convolutional neural network (CNN)

Classification using a machine learning algorithm has 2 phases:

Training phase: In this phase, we train a machine learning algorithm using a dataset comprised of the images and their corresponding labels.

Prediction phase: In this phase, we utilize the trained model to predict labels of unseen images.

The training phase for an image classification problem has 2 main steps:

Feature Extraction: In this phase, we utilize domain knowledge to extract new features that will be used by the machine learning algorithm. HoG and SIFT are examples of features used in image classification.

Model Training: In this phase, we utilize a clean dataset composed of the images' features and the corresponding labels to train the machine learning model.

In the predicition phase, we apply the same feature extraction process to the new images and we pass the features to the trained machine learning algorithm to predict the label.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.