Skip to content

📶 Visualize sorting algorithms via images.

Notifications You must be signed in to change notification settings

Muneer320/sort-image

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📶 Sort Image

Inspiration for this project is the following post from Reddit.


👷 Architecture

The flow of data is as follows: PIL is used for image manipulation, and either ffmpeg or opencv can be used to combine the generated images into a video.

"Architecture"


⚙️ Usage

  • Install ffmpeg (If you want to use it instead of opencv).
sudo apt install ffmpeg
  • Clone the repository:
git clone <https://github.com/surajkareppagol/sort-image>
cd sort-image
  • Set up a virtual environment:
python3 -m venv .venv
source .venv/bin/activate
  • Install dependencies:
pip install -r requirements_ffmpeg.txt
# OR
pip install -r requirements_opencv.txt
  • Run the script:
python3 src/main.py <path_to_image>

Additional Arguments

  1. Split Size Control the size of splits (default is 50):
python3 src/main.py <path_to_image> -s 50
  1. Sorting Algorithm Select the sorting algorithm by index:
python3 src/main.py <path_to_image> -s 100 -a 2

Here -a 2 selects Insertion Sort. Available algorithms can be seen below.

  1. Video Formatter Choose between ffmpeg and opencv (default is ffmpeg):
python3 src/main.py <path_to_image> -v opencv

📶 Sorting Algorithms

The following algorithms are available:

  1. Bubble Sort
  2. Selection Sort
  3. Insertion Sort
  4. Merge Sort
  5. Quick Sort
  6. Heap Sort

Each algorithm creates a visually unique sorting video, making it easier to understand the sorting process.


📦 Dependencies

  • Python 3.8+
  • PIL (Pillow) for image manipulation
  • ffmpeg or opencv for video creation

Install one of the following based on your preference:

  • requirements_ffmpeg.txt (for ffmpeg support)
  • requirements_opencv.txt (for opencv support)

About

📶 Visualize sorting algorithms via images.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%