This repository contains an implementation of median filter. The project aims to explore optimization possibilities for the algorithm. This task was issued at the University of Miskolc, Hungary in 2023.
The project uses a custom naive BMP parser, which is not suitable for processing any BMP file.
BMPs with the following parameters can be used:
- Windows format
- 32-bit color depth
- uncompressed
- reversed line order
- Photoshop-like channel order
Project is configured to build with MSVC, but the code itself is intended to be portable.
Executable binary (win-x64) and sample images can be downloaded from Releases page.
To generate noise to an image, run:
parallel.exe generate-noise <percentage> <input-files> <output-folder>
NOTE, that the output directory must exist before running the command, otherwise the output will not be saved. If the output file is already exists, the program will overwrite it.
E.g. to generate 15% noise to the input image, run:
parallel.exe generate-noise 0.15 ./img/0.bmp ./output
To apply median filter to an image, run:
parallel.exe median-filter <kernel-size> <sorting-function> <thread-count> <input-files> <output-folder>
Parameter | Description |
---|---|
kernel-size | Size of the kernel to be used. It is a single number (e.g. input 3 produces a 3x3 kernel).It is recommended to use an odd number. |
sorting-function | Sorting method to be used. Possible values are: bucket , bucket-parallel , quick , quick-parallel |
thread-count | Number of threads to be used. Possible values are:1 : serial execution,0 : dynamic parallel execution (OpenMP determines thread count),greater than zero: fixed thread count |
input-files | Images to process. It can be multiple files, delimited by | , e.g. pic0.bmp|pic1.bmp|pic2.bmp . |
output-folder | Path to a directory, where output files should be stored. The output files are named the same as the input. |
NOTE, that the output directory must exist before running the command, otherwise the output will not be saved. If the output file is already exists, the program will overwrite it.
E.g. to filter multiple images using a 3x3 kernel, quicksort algorithm, and 8 threads, run:
parallel.exe median-filter 3 quick 8 pic0.bmp|pic1.bmp|pic2.bmp ./out
Examples can be found here.
Sample images are published under certain Creative Commons licenses. Check URLs for more information.
- Mathias Appel - Siberian Tiger
- Stewart Nimmo - Fox Glacier, West Coast, New Zealand
- Andrew Shiva - Hungarian Parliament Building
- Andrey Gulivanov - Red Fox