All Projects → ahmetozlu → Color_recognition

ahmetozlu / Color_recognition

Licence: mit
🎨 Color recognition & classification & detection on webcam stream / on video / on single image using K-Nearest Neighbors (KNN) is trained with color histogram features by OpenCV.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Color recognition

Orange3
🍊 📊 💡 Orange: Interactive data analysis
Stars: ✭ 3,152 (+1946.75%)
Mutual labels:  data-science, classification, numpy
Machine Learning With Python
Practice and tutorial-style notebooks covering wide variety of machine learning techniques
Stars: ✭ 2,197 (+1326.62%)
Mutual labels:  data-science, classification, numpy
Php Ml
PHP-ML - Machine Learning library for PHP
Stars: ✭ 7,900 (+5029.87%)
Mutual labels:  data-science, classification, feature-extraction
Tsfel
An intuitive library to extract features from time series
Stars: ✭ 202 (+31.17%)
Mutual labels:  data-science, classification, feature-extraction
Kaggle Competitions
There are plenty of courses and tutorials that can help you learn machine learning from scratch but here in GitHub, I want to solve some Kaggle competitions as a comprehensive workflow with python packages. After reading, you can use this workflow to solve other real problems and use it as a template.
Stars: ✭ 86 (-44.16%)
Mutual labels:  data-science, classification, feature-extraction
Boxdetection
A Box detection algorithm for any image containing boxes.
Stars: ✭ 104 (-32.47%)
Mutual labels:  numpy, image-processing
Neuroflow
Artificial Neural Networks for Scala
Stars: ✭ 105 (-31.82%)
Mutual labels:  data-science, classification
Autoannotationtool
A label tool aim to reduce semantic segmentation label time, rectangle and polygon annotation is supported
Stars: ✭ 113 (-26.62%)
Mutual labels:  classification, image-processing
Steppy
Lightweight, Python library for fast and reproducible experimentation 🔬
Stars: ✭ 119 (-22.73%)
Mutual labels:  data-science, image-processing
Blurr
Data transformations for the ML era
Stars: ✭ 96 (-37.66%)
Mutual labels:  data-science, feature-extraction
Mlr
Machine Learning in R
Stars: ✭ 1,542 (+901.3%)
Mutual labels:  data-science, classification
Open Solution Salt Identification
Open solution to the TGS Salt Identification Challenge
Stars: ✭ 124 (-19.48%)
Mutual labels:  data-science, image-processing
Nni
An open source AutoML toolkit for automate machine learning lifecycle, including feature engineering, neural architecture search, model compression and hyper-parameter tuning.
Stars: ✭ 10,698 (+6846.75%)
Mutual labels:  data-science, feature-extraction
Python Bigdata
Data science and Big Data with Python
Stars: ✭ 112 (-27.27%)
Mutual labels:  data-science, numpy
Sspipe
Simple Smart Pipe: python productivity-tool for rapid data manipulation
Stars: ✭ 96 (-37.66%)
Mutual labels:  data-science, numpy
Seaborn Tutorial
This repository is my attempt to help Data Science aspirants gain necessary Data Visualization skills required to progress in their career. It includes all the types of plot offered by Seaborn, applied on random datasets.
Stars: ✭ 114 (-25.97%)
Mutual labels:  data-science, numpy
Tiny ml
numpy 实现的 周志华《机器学习》书中的算法及其他一些传统机器学习算法
Stars: ✭ 129 (-16.23%)
Mutual labels:  classification, numpy
Color Tracker
Color tracking with OpenCV
Stars: ✭ 128 (-16.88%)
Mutual labels:  numpy, image-processing
Ds Ai Tech Notes
📖 [译] 数据科学和人工智能技术笔记
Stars: ✭ 131 (-14.94%)
Mutual labels:  data-science, numpy
Interactive machine learning
IPython widgets, interactive plots, interactive machine learning
Stars: ✭ 140 (-9.09%)
Mutual labels:  data-science, classification

COLOR RECOGNITION

This project focuses on color classifying by K-Nearest Neighbors Machine Learning Classifier which is trained by R, G, B Color Histogram. It can classify White, Black, Red, Green, Blue, Orange, Yellow and Violet. If you want to classify more color or improve the accuracy you should work on the training data or consider about other color features such as Color Moments or Color Correlogram.

You can use color_recognition_api to perform real-time color recognition in your projects. You can find a sample usage of color_recognition_api in this repo. Please contact if you need professional color recognition project with the super high accuracy!

Quick Demo

Run color_classification_webcam.py to perform real-time color recognition on a webcam stream.

Run color_classification_image.py to perform color recognition on a single image.


What does this program do?

  1. Feature Extraction: Perform feature extraction for getting the R, G, B Color Histogram values of training images
  2. Training K-Nearest Neighbors Classifier: Train KNN classifier by R, G, B Color Histogram values
  3. Classifying by Trained KNN: Read Web Cam frame by frame, perform feature extraction on each frame and then classify the mean color of it by trained KNN classifier.

TODOs:

  • "Add New Color" utility will be added.
  • New feature extractors will be added.
  • New classifiers will be added.

Theory

In this study, colors are classified by using K-Neares Neşghbor Machine Learning classifier algorithm. This classifier is trained by image R, G, B Color Histogram values. The general work flow is given at the below.

You should know 2 main pheomena to understand basic Object Detection/Recognition Systems of Computer Vision and Machine Learning.

1.) Feature Extraction

How to represent the interesting points we found to compare them with other interesting points (features) in the image.

2.) Classification

An algorithm that implements classification, especially in a concrete implementation, is known as a classifier. The term "classifier" sometimes also refers to the mathematical function, implemented by a classification algorithm, that maps input data to a category.

For this project;

1.) Feature Extraction = Color Histogram

Color Histogram is a representation of the distribution of colors in an image. For digital images, a color histogram represents the number of pixels that have colors in each of a fixed list of color ranges, that span the image's color space, the set of all possible colors.

2.) Classification = K-Nearest Neighbors Algorithm

K nearest neighbors is a simple algorithm that stores all available cases and classifies new cases based on a similarity measure (e.g., distance functions). KNN has been used in statistical estimation and pattern recognition already in the beginning of 1970’s as a non-parametric technique.

Implementation

OpenCV was used for color histogram calculations and knn classifier. NumPy was used for matrix/n-dimensional array calculations. The program was developed on Python at Linux environment.

In the “src” folder, there are 2 Python classes which are:

In the “color_recognition_api” folder, there are 2 Python classes which are:

1.) Explanation of “feature_extraction.py"

I can get the RGB color histogram of images by this Python class. For example, plot of RGB color histogram for one of the red images is given at the below.

I decided to use bin number of histogram which has the peak value of pixel count for R, G and B as feature so I can get the dominant R, G and B values to create feature vectors for training. For example, the dominant R, G and B values of the red image which is given at above is [254, 0, 2].

I get the dominant R, G, B values by using Color Histogram for each training image then I labelled them because KNN classifier is a supervised learner and I deploy these feature vectors in the csv file. Thus, I create my training feature vector dataset. It can be found in the file which name’s is training.data under src folder.

2.) Explanation of “knn_classifier.py

This class provides these main calculations;

  1. Fetching training data
  2. Fetching test image features
  3. Calculating euclidean distance
  4. Getting k nearest neighbors
  5. Prediction of color
  6. Returning the prediction is true or false

color_classification_webcam.py is the main class of my program, it provides;

  1. Calling feature_extraction.py to create training data by feature extraction
  2. Calling knn_classifier.py for classification

You can find training data in here.

You can find features are got from training data in here.

Conclusion

I think, the training data has a huge important in classification accuracy. I created my training data carefully but maybe the accuracy can be higher with more suitable training data.

Another important thing is lightning and shadows. In my test images, the images which were taken under bad lighting conditions and with shadows are classified wrong (false positives), maybe some filtering algorithm should/can be implemented before the test images send to KNN classifier Thus, accuracy can be improved.

Citation

If you use this code for your publications, please cite it as:

@ONLINE{cr,
    author = "Ahmet Özlü",
    title  = "Color Recognition",
    year   = "2018",
    url    = "https://github.com/ahmetozlu/color_recognition"
}

Author

Ahmet Özlü

License

This system is available under the MIT license. See the LICENSE file for more info.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].