A median filter implementation using C++. Currently supports grayscale images only.
Algorithms used:
- Merge Sort
- Median Filter
- OpenCV C++ Library (Required)- must set
binfolder to environment variables orPATH - Visual Studio (Optional) - For building the source code. Not required if using prebuilt binary files.
- VS Development Kit for C++ (Optional)
Median_Filter_CLI.exe <option> <argument>
Options:
--input <filepath>or-i <filepath>specify the file path image source.--output <filepath>or-o <filepath>specifies the save path of a filtered image--window <window size>or-w <window size>specify the window size (It must be greater than or equal 3 and an odd number). Will set to 3 as a default if specified incorrectly--log <save_path\filename>enables detailed logging of merge sort and pixel manipulation and specifies the save path of the log file--verboseoutputs each pixel being currently manipulated into the console.--enable-previewshows the filtered image
Using Powershell:
The following command reads the C:\Users\billg\Pictures\noisy_image.png as an image source. The program will set the window size to 3 after the filter process, the program will preview the filtered image and waits for the user to press any key. Finally, the save the image in C:\Users\billg\Pictures\ with file name
denoise_image.png
.\Median_Filter_CLI.exe --input C:\Users\billg\Pictures\noisy_image.png --output C:\Users\billg\Pictures\denoise_image.png --window 3 --enable-preview
This can also be written as:
.\Median_Filter_CLI.exe -i C:\Users\billg\Pictures\noisy_image.png -o C:\Users\billg\Pictures\denoise_image.png -w 3 --enable-preview
(This section is still being updated) If you want to build the code from scratch here are the steps:
- Install OpenCV and set the
binfolder to environment variables orPATH - Run the solution file on visual studio
- Set the include directories, libraries, and linkers in the project properties. Instructions for setting up OpenCV Libraries can be found here: https://subwaymatch.medium.com/opencv-410-with-vs-2019-3d0bc0c81d96
- Build the code and run