This was the preparation part for images and now we are ready to go on with clustering. Besides, it is hard to deal with 3-D Matrix that’s why we reshape() image and make it 2-D Matrix data. But, we won’t need row and column information separately. Now we have 3-D parameters in our image data: row number X column number X colour channel number. But we want Red-Green-Blue as our image color channel, so we convert it to the required channel using cv2.cvtcolor() function. Once the image is read using cv2, our image color channel comes to us as Blue-Green-Red. The other libraries that I have used NumPy for numerical arrays, Matplotlib for visualizing my result, Sklearn for machine learning.įirst we will read image data using cv2.imread() function from OpenCV as cv2. Project DetailsĪs, I have mentioned previously I used OpenCV library for image processing with Python3 for this project. Examining the centroid feature weights can be used to qualitatively interpret what kind of group each cluster represents.įor more information you can read this blog post. The “Choosing K” section below describes how the number of groups can be determined.Įach centroid of a cluster is a collection of feature values which define the resulting groups. Rather than defining groups before looking at the data, clustering allows you to find and analyze the groups that have been formed organically. Labels for the training data (each data point is assigned to a single cluster).The centroids of the K clusters, which can be used to label new data.The results of the K-means clustering algorithm are: Data points are clustered based on feature similarity. The algorithm works iteratively to assign each data point to one of K groups based on the features that are provided. The goal of this algorithm is to find groups in the data, with the number of groups represented by the variable K. If data set samples have labels, we prefer to use supervised method, but in real world mostly we don’t have labels and that’s why we prefer clustering methods which are known as unsupervised methods. K-Means Clustering is an unsupervised learning method. I used k-means clustering to cluster the colors instead of using histogram for each color of pixel. OpenCV (Open Source Computer Vision Library) is released under a BSD license and hence it’s free for both academic and commercial use. In this project, I have written code using python3 with OpenCV. You can find the paper of that project in here. Of course, it may not be that simple but this project should be a basic project to learn K-Means Clustering.Īfter I published this blog post, I did a real life project using this approach along with others. So, if green color is dominant it means that it’s not the important frame and you can eliminate it. And you can basically presume that if the moment is important you camera will leave the playground and focus to football player. Yay! All I have to do is to find the dominant color for each frame of video. But what if you don’t like football? :) Yes, I don’t like football and I’m a computer scientist. But you must be thinking, why would we need this?Ĭonsider that you need to summarize the most important moments of a football match and you are a computer scientist, how would you solve that problem? If you like to watch football you may prefer to watch and decide which moments are most important by yourself. The project aims to find the dominant color of an image. Therefore, I decided to start my first machine learning post with this project. When I started to learn image recognition, this was the first real project I have ever done, and it was fun.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |