Contact Us
All Case Studies
Computer Vision

Bag of Visual Words for Image Classification

Classifying cats, chairs and cameras with SIFT, KMeans, KNN & SVM.

202595% Best class accuracy (SVM)
OVERVIEW

The Project

A Bag of Visual Words (BoVW) pipeline for image classification using handcrafted SIFT descriptors, KMeans clustering, and KNN/SVM classifiers, classifying images of three object categories: cats, chairs, and cameras.

Objectives

  • Build a robust feature-extraction pipeline using SIFT.
  • Apply KMeans to create a visual vocabulary.
  • Train KNN and SVM models to classify unseen test images.
  • Visualize histogram representations and predictions.
  • Tools & Technologies

    PythonOpenCVSIFTKMeansKNN & SVMMatplotlib
    FIGURES

    Charts & Graphs

    Bag-of-Visual-Words classification result (1)
    Bag-of-Visual-Words classification result (1)
    Bag-of-Visual-Words classification result (2)
    Bag-of-Visual-Words classification result (2)
    METHODOLOGY

    The Approach

    1

    Load images and convert to grayscale; extract SIFT keypoints and descriptors into a feature pool.

    2

    Cluster all descriptors with KMeans (k = 200) — each centre becomes a visual word.

    3

    Encode each image as a histogram of visual words.

    4

    Train KNN (k = 5) and a linear SVM on the histograms, then predict on unseen images.

    OUTCOME

    Results & Learnings

  • SVM outperformed KNN — Cat 90%, Chair 82%, Camera 95%.
  • Histogram encoding drastically reduced image complexity.
  • Visualizations helped debug class confusion.
  • Key Learnings

    • BoVW works effectively with SIFT and simple classifiers.
    • Clustering + classical ML can build powerful vision systems.
    CONTACT US

    Let's Discuss YourNext Project

    Ready to build something exceptional? Share your idea and we'll respond with a clear plan, honest timeline, and competitive quote within 24 hours.