An image filter toolkit
The problem
Write a set of image filters that work on NumPy arrays: crop, flip, brightness and contrast, threshold, greyscale conversion and a simple blur.
Requirements
- Functions that take and return uint8 arrays without changing the input
- Brightness and contrast with a wider dtype and np.clip
- Greyscale conversion of an (h, w, 3) array with a weighted sum over the channel axis
- A 3 × 3 box blur written with slicing instead of loops over pixels
Technologies
- Python 3
- NumPy
- Slicing and views
- Broadcasting and clipping
Step by step
- Build small test images as arrays and print them.
- Write and test crop, flip and threshold.
- Add brightness, contrast and greyscale with correct dtypes.
- Write the blur with slicing and compare it with a slow loop version.
Expected result
A module of tested filter functions that could be used on real photos loaded with an imaging library.
How it is evaluated
- No filter wraps around or changes its input
- Shapes and dtypes are preserved
- The blur matches the loop version
- Each function is short and documented
Ways to improve it
- Add edge detection
- Add histogram equalisation
- Process a batch of images in one 4-D array