abhijitmahalle / k-means-image-segmentation

Implementation of k-means algorithm for image segmentation

Repository from Github https://github.comabhijitmahalle/k-means-image-segmentationRepository from Github https://github.comabhijitmahalle/k-means-image-segmentation

License: MIT

Image segmentation using k-means algorithm

This repository contains program to perform image segmentation i.e. dividing the image into user-defined number of classes using k-means algorithm. The algorithm has been implemented from scratch without using any inbuilt cv2 function. The below image of "traffic signal" has been divided into 4 classes.

Requirement:

  • Python 2.0 or above

Dependencies:

  • OpenCV
  • NumPy

Instruction to run the code:

python k_means.py

Result

Fig. 1 - Original image                                Fig. 2 - Segmented image

About

Implementation of k-means algorithm for image segmentation


Languages

Language:Python 100.0%