Inspiration for this project is the following post from Reddit.
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.
- Install
ffmpeg
(If you want to use it instead ofopencv
).
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>
- Split Size
Control the size of splits (default is
50
):
python3 src/main.py <path_to_image> -s 50
- 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.
- Video Formatter
Choose between
ffmpeg
andopencv
(default isffmpeg
):
python3 src/main.py <path_to_image> -v opencv
The following algorithms are available:
Bubble Sort
Selection Sort
Insertion Sort
Merge Sort
Quick Sort
Heap Sort
Each algorithm creates a visually unique sorting video, making it easier to understand the sorting process.
- Python 3.8+
PIL
(Pillow) for image manipulationffmpeg
oropencv
for video creation
Install one of the following based on your preference:
requirements_ffmpeg.txt
(forffmpeg
support)requirements_opencv.txt
(foropencv
support)