A simple Python project for experimenting with classic image filtering and segmentation techniques using OpenCV and NumPy.
- Applies low-pass (smoothing) and median filters to images
- Performs edge detection using the Canny algorithm
- Segments images using:
- K-means clustering
- Region growing
- Global and adaptive thresholding
- Python 3.x
- OpenCV (
opencv-python) - NumPy
-
Install dependencies:
pip install opencv-python numpy
-
Set your image path:
Each script contains a placeholder line such as:
img = cv2.imread('c:/path/to/image.png') # <-- Placeholder path
Update this path to point to your own image file.
-
Run a script:
For example, to run the k-means segmentation:
python Segmentation/k-means.py
Or to apply a median filter:
python Filtering/medium-filter.py
Each script will display the processed image in a window.
-
Filtering/
low-pass-filter.py: Applies a 5x5 averaging filtermedium-filter.py: Applies a 5x5 median filteredge-detection.py: Detects edges using Canny
-
Segmentation/
k-means.py: Segments image colours using k-means clusteringregion-growth.py: Segments regions based on intensity similaritythresholding.py: Performs global and adaptive thresholding
- Ensure you update the image path in each script before running.
- All scripts open a window to display results; press any key to close.