Skip to content

Image Segmentation Program using the k-means clustering algorithm

Notifications You must be signed in to change notification settings

RexWangSida/ImageSegmentationProgram

Repository files navigation

Image Segmentation Program

Small Python program performing image segmentation using k-means clustering algorithm

Supported Image Types

  • JPEG(.jpg)
  • PNG(.png)

Python Libraries

  • Scikit-Learn & Scikit-Image
    • Basic usage of k-means algorithm and image image loading.
  • Numpy
    • Matrix operations
  • Pillow(PIL)
    • Image convert
  • Tkinter
    • GUI

Run the Program

  • This can be done in Windows PowerShell or Linux/Mac Terminal, and it requires git, python, Numpy, PIL, Tkinter and Scikit, or at least pip.
  • The instruction of how to install python can be found at HERE.
  • The instruction of how to install pip can be found at HERE.
  • The instruction of how to install git can be found at HERE.
  • The Tkinter is included in python standard libraries and does not need specific installation once python is installed.
  • To install numpy(it requires pip to be installed), run:
pip install numpy
  • To install PIL(it requires pip to be installed), run:
pip install Pillow
  • To install Scikit(it requires pip to be installed), run:
pip install -U scikit-learn

and

pip install scikit-image
  • To start the program, sequentially run:
git clone https://github.com/RexWangSida/ImageSegmentationProgram.git
cd ImageSegmentationProgram
python frame.py

GUI

Examples of the image processing

Original Image

One Segment(One Cluster k == 1)

Two Segments(Two Clusters k == 2)

Three Segments(Three Clusters k == 3)

Four Segments(Four Clusters k == 4)

Five Segments(Five Clusters k == 5)

Six Segments(Six Clusters k == 6)

Seven Segments(Seven Clusters k == 7)

Eight Segments(Eight Clusters k == 8)

Nine Segments(Nine Clusters k == 9)

Ten Segments(Ten Clusters k == 10)