Giter Site home page Giter Site logo

stinsan / sorting-randomized-images Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 96.23 MB

A command-line program to visualize sorting algorithms by randomizing an image and then allowing a given algorithm to re-sort it.

License: MIT License

Python 100.00%
sorting sorting-algorithm sorting-algorithms sorting-algorithms-implemented sorting-visualization algorithms-implemented algorithm-visualization pil-library image-manipulation pil

sorting-randomized-images's Introduction

Sorting Randomized Images and the Visualization of Sorting Algorithms

License: MIT made-with-python

Getting Started โœ”๏ธ

Prerequisites

This program uses the following Python modules:

  • Pillow
pip install Pillow
  • NumPy
pip install numpy
  • OpenCV
pip install opencv

Installation

  • First, clone this repository.
git clone https://github.com/stinsan/Sorting-Randomized-Images.git
  • Then, the H264 video codec must also be installed becuase OpenCV does not include it in the default installation.
    After downloading, unzip the file, then place the .dll file in the same directory as main.py.
    Download the latest release from here: https://github.com/cisco/openh264/releases

Running the Program ๐Ÿƒ

The program is invoked by the following command:

python main.py <sorting_algorithm>

The <sorting_algorithm> parameter can be one of the following:

Parameter Name Sorting Algorithm Used
bubble Bubblesort
insert Insertion Sort
select Selection Sort
dselect Double Selection Sort
merge Merge Sort
quick Quicksort
heap Heapsort
count Counting Sort
radix Radix Sort
bucket Bucket Sort

If no parameter is set, the program defaults to using bubblesort.

Then, the user will be prompted to select an image that will be randomized and sorted.

After a few seconds, a video showing the sorting algorithm at work will open and begin playing. This video will also be saved in the same directory as the program as "result.mp4".

The statistics of the sorting algorithm, such as the number of array comparisons and swaps, will also be output to the terminal.

Examples and Results ๐Ÿ’ฏ

Here is an example of how this program works and the results that come from it.

Take this cute picture of myself as the input image:

This is the image after randomization:

This is a snippet of the resulting video showing a visualization of how the sorting algorithm works (bubblesort, in this case):

These are the statistics that are printed to the terminal:

TODO ๐Ÿ“œ

  • Insertion sort
  • Selection sort
  • Double selection sort
  • Merge sort
  • Quicksort
  • Heapsort
  • Counting sort
  • Radix sort
  • Bucket sort
  • GUI
  • Optimizations

sorting-randomized-images's People

Contributors

stinsan avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.