Image Segmentation using OpenCV

Image for post
Image for post

What is Image Segmentation ?

Usage of Segmentation in real world applications

Image segmentation Techniques

Image for post
Image for post
Comparison between Different Techniques

Clustering Based Segmentation Methods

Code Implementation

Import Libraries

Image for post
Image for post

Load Input Image and process it on OpenCV

Image for post
Image for post

Steps to perform segmentation

Image for post
Image for post

Understanding Parameters for K-Means Clustering in OpenCV

Input parameters

Output parameters

Image for post
Image for post

Construct the segmented image

Image for post
Image for post
Image for post
Image for post

Disabling some clusters to visualize the segment they represented.

Image for post
Image for post
Image for post
Image for post
Cluster 1 represented the Green color as disabling cluster 1 or making it black is evident in the image

Similarly trying with number of clusters to be segmented upon as 8 and visualizing the image

Image for post
Image for post
Image for post
Image for post
Count associated with each Cluster
Image for post
Image for post
Disabling Cluster 4, assign black color to the pixels representing segment 4
Image for post
Image for post

Similarly disabling Cluster 2

Image for post
Image for post

Conclusion:

Machine Learning and Deep Learning enthusiast

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store