Skip to content

Sorts the pixels in an image. It implements Quicksort as its sorting algorithm. I wrote it as part of my algorithm class in university.

License

Notifications You must be signed in to change notification settings

simonldwg/PictureSort

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PictureSort

This is a Python script that sorts the pixels in an image. It implements Quicksort as its sorting algorithm. I wrote it as part of my algorithm class in university. The program requires a recent version of Python 3.

Getting started

  1. Create a new environment using venv:
    python -m venv venv
  2. Activate the environment:
    Linux:
    source venv/bin/activate
    Windows (PowerShell)
    .\venv\Scripts\activate.ps1
  3. Install requirements:
    pip install -r requirements.txt

Usage

To use this script, you have to provide it with a source and destination filename:

python main.py source_file.jpg destination_file.jpg

By default, the scripts sorts each row of pixels by luminance. The script has been verified to work with JPEG and PNG. For a list of supported file formats, take a look at the Pillow image library wiki. Please note: Sorting a high-resolution image can take a long time, especially sorting it continuously.

Examples

The original image:
The original example image
Each row sorted by luminance:
Each row sorted by luminance
Each column sorted by luminance:
Each column sorted by luminance
The whole image sorted by luminance continuously:
The whole image sorted by luminance continuously
Each row sorted by the red value:
Each row sorted by the red value

Options

Argument Values Default Explanation
--sort rows, columns, continuously rows Specifies how the image will be sorted. You can sort each row, each column or sort the image continuously.
--sort-by red, green, blue, luminance luminance Specifies which value will be the sorting key.

About

Sorts the pixels in an image. It implements Quicksort as its sorting algorithm. I wrote it as part of my algorithm class in university.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages