High Performance Computing | Universidad Politecnica de Yucatan (UPY) Data Engineering — 7th Quadrimester | March 2026 Students:
- Balam Euan Cesar Arturo
- De Gante Pérez Diego
- Polanco González Roselyn
Implementation and performance comparison of three classical grayscale image filters under three computational strategies:
| Strategy | Description |
|---|---|
| Pure Python | Standard Python loops; no external libraries in filter logic. Serves as the performance baseline. |
| NumPy | Vectorised array operations delegated to NumPy's C/BLAS back-end. |
| Cython | Compiled native extension with typed memoryviews and C-level arithmetic. |
| Filter | Type | Purpose |
|---|---|---|
| Gaussian | Linear | Weighted-average blur for noise reduction |
| Sobel | Linear | Gradient-magnitude edge detection (Kx + Ky) |
| Median | Non-linear | Impulse (salt-and-pepper) noise removal |
EA2_U2/
│
├── src/ # All filter source code
│ ├── filters_pure_python.py # Pure Python implementations (baseline)
│ ├── filters_numpy.py # NumPy vectorised implementations
│ ├── filters_cython.pyx # Cython source (compiled to native extension)
│ └── setup.py # Build script for the Cython extension
│
├── scripts/
│ └── main.py # Benchmark runner + visualisation + summary table
│
├── assets/
│ └── test_image.png # Input image (auto-generated if missing)
│
├── output/ # All generated images (auto-created on first run)
│ ├── out_pure_gaussian.png
│ ├── out_pure_sobel.png
│ ├── out_pure_median.png
│ ├── out_numpy_gaussian.png
│ ├── out_numpy_sobel.png
│ ├── out_numpy_median.png
│ ├── out_cython_gaussian.png
│ ├── out_cython_sobel.png
│ ├── out_cython_median.png
│ ├── comparison_grid.png
│ └── timing_chart.png
│
├── report/
│ └── Image_Processing_Unit2_Report.docx
│
├── .gitignore
├── requirements.txt
└── README.md
Note:
assets/andoutput/are created automatically on the first run if they do not exist. You do not need to create them manually.
- Python >= 3.10
- A C compiler (GCC / Clang on Linux or macOS; MSVC or MinGW on Windows)
From the project root:
pip install -r requirements.txtThe Pure Python and NumPy filters run without any build step. Cython requires compilation:
cd src
python setup.py build_ext --inplace
cd ..This produces a platform-specific shared library inside src/, for example:
src/filters_cython.cpython-311-x86_64-linux-gnu.so (Linux)
src/filters_cython.cpython-311-darwin.so (macOS)
src/filters_cython.cp311-win_amd64.pyd (Windows)
If the extension is not built, main.py will skip the Cython results
and print a reminder, but the rest of the benchmark runs normally.
From the project root (EA2_U2/):
# Use the auto-generated synthetic test image
python scripts/main.py
# Use your own image
python scripts/main.py path/to/your/image.pngAll output images and charts are saved to output/ automatically.
| File | Description |
|---|---|
output/out_pure_gaussian.png |
Gaussian — Pure Python |
output/out_pure_sobel.png |
Sobel — Pure Python |
output/out_pure_median.png |
Median — Pure Python |
output/out_numpy_gaussian.png |
Gaussian — NumPy |
output/out_numpy_sobel.png |
Sobel — NumPy |
output/out_numpy_median.png |
Median — NumPy |
output/out_cython_gaussian.png |
Gaussian — Cython |
output/out_cython_sobel.png |
Sobel — Cython |
output/out_cython_median.png |
Median — Cython |
output/comparison_grid.png |
Side-by-side filter comparison (NumPy) |
output/timing_chart.png |
Grouped bar chart of execution times (log scale) |
| Filter | Pure Python (s) | NumPy (s) | Cython (est., s) | Speedup (Py / Cy) |
|---|---|---|---|---|
| Gaussian | 0.5992 | 0.0025 | ~0.0003 | ~2000x |
| Sobel | 0.2059 | 0.0040 | ~0.0006 | ~340x |
| Median | 0.0923 | 0.0258 | ~0.0038 | ~24x |
Recommended entries to keep the repository clean:
# Cython build artifacts
src/*.so
src/*.pyd
src/*.c
src/*.html
build/
# Generated output images (large binary files)
output/
# Python cache
__pycache__/
*.pyc