An optimization-driven remake of CS50's Filter (Harder) project. This application breaks free from the limitations of the original C language version by replacing custom BMP parser data structures with standard system file explorer prompts and multi-format support (PNG, JPEG, BMP, WebP), while running image kernels at lightning-fast hardware speeds using vectorized math matrices.
- Multi-Format Processing: Seamlessly load and save all modern standard image types via Pillow integration instead of manual 24-bit uncompressed BMP parsing.
- Native GUI File Picker: No more tedious terminal string typing. The script hooks directly into your operating system's native window dialog to open files and select target saving coordinates.
- Hardware Vectorization Boost: Replaced heavy Python nested
forloop logic—which takes minutes to step through millions of pixels—with pre-compiled C-speed NumPy matrix operations that run complex kernels in milliseconds. - Portable Automation Shell: Includes an interactive batch command menu interface you can pin straight to your desktop as a portable launch shortcut.
The system is cleanly divided into two specialized standalone components:
filter.py: The application driver. It reads parameter flags, invokes OS file dialog abstractions, processes the Pillow-to-NumPy coordinate conversions, and handles safety clipping metrics.helpers.py: The pure mathematics layer. Houses the structural algorithmic modifications for image modifications.
-
-g(Grayscale): Maps color channels down to exact average channel intensities. -
-r(Reflect): Mirrors column arrays horizontally across matrix lines. -
-b(Blur): Implements a 3x3 array box neighborhood shift average algorithm. -
-e(Edges): Computes image structural vectors via horizontal ($G_x$ ) and vertical ($G_y$ ) Sobel kernel operators.
Make sure you have Python 3 installed on your machine.
-
Clone your repository down to your local directory:
git clone https://github.com cd YOUR_REPO_NAME -
Install the necessary mathematical and imaging dependencies:
pip install pillow numpy
Run the automated shell file locally or via your desktop shortcut:
./Run_Filter.batSimply choose a flag in the command prompt menu (e.g. -e), select your image when the file picker appears, and enter a new filename when prompted.
If you prefer explicit terminal calls, pass your required algorithm flag directly to the driver script:
python filter.py -eThis project highlights a massive milestone in software optimization:
- Why Python Loops Drag: Writing standard
for r in range(height):lines over standard high-definition photo grids forces the Python interpreter to read operations line-by-line over millions of pixels, grinding calculations to a halt. - The Power of Vectorization: By mapping the calculations onto multi-dimensional array slices (
np.pad,np.sqrt), the operations bypass standard runtime execution loops entirely and move directly onto pre-compiled C binaries inside the underlying hardware layout, matching C performance with just a few clean lines of code.