Code snippet to seperate different type of blobs according to their radius with the help of OpenCV and Matplotlib library in python 3.
Image segmentation is an essential preliminary step in most automatic pictorial pattern recognition and scene analysis applications.
- VS Code 1.60.1
- Python 3
- Ubuntu 20.04.3 LTS 64-bit
First you must have these libraries and languages installed on your system -
To run the code, run this commands in terminal with main.py as in current directory and images in Images folder along with main.py
$ python3 main.py
Window will pop-up with resultant images and their histograms.
Method used here simply involves following steps :-
- Converting provided image to grayscale image.
- Applying binary threshold of value 100, if pixel value is greater han 100 it will be considered as 255 else 0.
- Using Canny Edge Detection to seperate different blobs.
- cv2.findContours() is helpful in retrieving contours from the binary image. The contours are a useful tool for shape analysis and object detection.
- We then seperate all different radius from image.
- We draw those bolbs seperately on seperate images.
Completed
- Images used in this project may be subject to copyright.
- Digital Image Processing (Third Edition) by Rafael C. Gonzalez and Richard E. Woods
- OpenCV Documentation
- Matplotlib Documentation
This code is contributed by Abhinav Sharma.