https://github.com/chaganti-reddy/ispso
Image Segmentation Using Particle Swarm Optimization & K-means Clustering Algorithm
https://github.com/chaganti-reddy/ispso
dockerization flask-application image-segmentation particle-swarm-optimization python3
Last synced: 28 days ago
JSON representation
Image Segmentation Using Particle Swarm Optimization & K-means Clustering Algorithm
- Host: GitHub
- URL: https://github.com/chaganti-reddy/ispso
- Owner: Chaganti-Reddy
- License: mit
- Created: 2023-04-30T11:27:27.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2025-05-14T06:37:11.000Z (11 months ago)
- Last Synced: 2025-07-19T09:49:07.198Z (8 months ago)
- Topics: dockerization, flask-application, image-segmentation, particle-swarm-optimization, python3
- Language: Python
- Homepage: https://github.com/Chaganti-Reddy/ISPSO
- Size: 3.58 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Image Segmentation Using PSO
## Table of Content
- [Flight Fare Prediction:](#flight-fare-prediction)
- [Table of Content](#table-of-content)
- [Overview](#overview)
- [What is this project about?](#motivation)
- [π Prerequisites](#key-prerequisites)
- [π Data Preprocessing](#book-data-preprocessing)
- [πΒ Installation](#-installation)
- [π‘ How to Run](#bulb-how-to-run)
- [Results](#results)
- [Directory Tree](#directory-tree)
- [Technologies Used](#technologies-used)
- [Future Scope](#future-scope)
- [π And it's done!](#clap-and-its-done)
- [π Citation](#raising_hand-citation)
- [β€οΈ Owner](#heart-owner)
- [π License](#eyes-license)
## Overview
This is a Flask web app which shows the images after segmenting using PSO.
## What is this project about?
Particle Swarm Optimization (PSO) is a popular optimization technique inspired by the collective behavior of bird flocking or fish schooling. It is commonly used to solve optimization problems in various fields, including image processing.
Image segmentation is the process of partitioning an image into multiple segments or regions based on certain criteria, such as color, texture, or intensity. It is a fundamental task in computer vision, and it has various applications, including object recognition, image analysis, and medical imaging.
PSO can be used for image segmentation because it is a powerful optimization technique that can find the optimal segmentation parameters by searching the solution space efficiently. PSO-based image segmentation algorithms typically define the fitness function based on the similarity of the segmented

Velocity Vector Update Equation:
$$
\begin{equation}
\mathbf{v_{id}}(t+1) = w \mathbf{v_{id}}(t) + c_1 rand() \left( \mathbf{p_{id}}(t) - \mathbf{x_{id}}(t) \right) + c_2 rand() \left( \mathbf{v_{gd}}(t) - \mathbf{x_{gd}}(t) \right)
\end{equation}
$$
Position Vector Update Equation:
$$
\begin{equation}
\mathbf{x_{id}}(t+1) = \mathbf{x_{id}}(t) + \mathbf{v_{id}}(t+1)
\end{equation}
$$
Inertia Weight:
$$
\begin{equation}
w = w_{max} - \frac{w_{max} - w_{min}}{iter_{max}} \times iter
\end{equation}
$$
## π Prerequisites
All the dependencies and required libraries are included in the file requirements.txt [See here](requirements.txt)
## π Data Preprocessing
Data pre-processing is an important step for the creation of a machine learning
model. Initially, data may not be clean or in the required format for the model which
can cause misleading outcomes. In pre-processing of data, we transform data into our
required format. It is used to deal with noises, duplicates, and missing values of the
dataset. Data pre-processing has the activities like importing datasets, splitting
datasets, attribute scaling, etc. Preprocessing of data is required for improving the
accuracy of the model.
## πΒ Installation
The Code is written in Python 3.9. If you donβt have Python installed you can find it [here](https://www.python.org/downloads/). If you are using a lower version of Python you can upgrade using the pip package, ensuring you have the latest version of pip. To install the required packages and libraries, run this command in the project directory after [cloning](https://www.howtogeek.com/451360/how-to-clone-a-github-repository/) the repository:
1. Clone the repo
```bash
git clone https://github.com/Chaganti-Reddy/ISPSO.git
```
2. Change your directory to the cloned repo
```bash
cd ISPSO
```
3. Now, run the following command in your Terminal/Command Prompt to install the libraries required
```bash
python3 -m virtualenv my_env
source my_env/bin/activate
pip3 install -r requirements.txt
```
### π‘ How to Run
1. Open terminal. Go into the cloned project directory and type the following command:
```bash
python3 app.py
```
2. The other method is you can directly pull this project from my Dockerhub using:
```bash
docker pull chagantireddy/ispso:latest
```
3. Then run using:
```bash
docker run -it --rm -p 5000:5000 chagantireddy/ispso:latest
```
## Results
Color Image

Gray Scale Image

## Directory Tree
```bash
.
βββ app.py
βββ Dockerfile
βββ LICENSE
βββ pso.py
βββ Readme.md
βββ requirements.txt
βββ static
βΒ Β βββ segmented_image.jpg
βΒ Β βββ temp.jpg
βββ templates
βΒ Β βββ index.html
βΒ Β βββ result.html
βββ tests
βββ image.jpg
βββ lena.png
βββ tst.jpg
```
## Technologies Used
[
](https://numpy.org/) [
](https://www.python.org/) [
](https://www.docker.com/)[
](https://git-scm.com/)
## Future Scope
- To run it in more speed
- Optimize Flask app.py
- Optimize this Image Segmentation with different algorithm
## π And it's done!
Feel free to mail me for any doubts/query
βοΈ chagantivenkataramireddy1@gmail.com
---
## π Citation
You are allowed to cite any part of the code or our dataset. You can use it in your Research Work or Project. Remember to provide credit to the Maintainer Chaganti Reddy by mentioning a link to this repository and his GitHub Profile.
Follow this format:
- Author's name - Chaganti Reddy
- Date of publication or update in parentheses.
- Title or description of document.
- URL.
## β€οΈ Owner
Made with β€οΈΒ by [Chaganti Reddy](https://github.com/Chaganti-Reddy/)
## π License
MIT Β© [Chaganti Reddy](https://github.com/Chaganti-Reddy/ISPSO/blob/main/LICENSE)