OpenCV - Machine learning with Image Colors - opencv

I want to do a program in which:
Input = Image
Output = What color does it have
Im new to Machine Learning, and i want to learn. But i really don't know where to start. Can somebody give me some pointers? Any help would be appreciated!

Try looking into scikit-image library if you're familiar with Python. You don't really need machine-learning, just a lot of processing for this.
If you're just trying to find the "majority" color in an image then my approach would be the following:
Get an array of all the RGB values in an image.
Find the most commonly occurring pixel values.
Lookup the pixel value from this table
Return the name of the color.
This should get you started on your image analysis journey.

Related

Find pixel coordinates in an input image in keypoint matching algorithm using opencv?

I want to find out a given image in an input image......first I used template matching using opencv but its not giving proper result. So I switched to keypoint matching using SIFT with opencv. But I am not able to find pixel location in a input image. Someone please help me I am looking everywhere but not able to solve my problem
It is a multifaceted problem. Its easier to help with specific questions or problems.
This tutorial on Youtube helped me with this problem.

How do I go about reading the value of a dice face using OpenCV?

I'm new to image processing and have been pondering this question for a while now but I can't seem to find the right solution. I was thinking template matching but then the template may not be the same scale as its occurrence in the input image or it may not be in the same orientation as its occurrence in the input image. The only other way I can think of is by finding all the black colored blobs within a certain distance of each other and getting the number of those blobs. If so how do i do this? If there is a better method please enlighten me. Thank you.

Aggregate shapes to new shape in OpenCV

I'm trying to detect an object composed of other objects. Actualy, there are three circles in my binary image which shape up a triangle as shown here:
These circles are correctly detected, but only as single objects as shown here:
What I need to have is an aggregation or composition of these objects, so they get detected as one big object as shown here:
The bigger goal is to get the image moments to get the rotation and scale of the shape. Please share your ideas or code if you have any, it would be well appreciated.
I would suggest using the bounding box functions of opencv
Here is a link to an example of bounding box in C++ OpenCV, however if you are using something like Python, it might be worth your while looking at this link, which is a full set of tutorials for working with binary images and contours (including bounding box/elipse)
Again if you are using the Python port, look at this set of tutorials, they really are great and have a massive supply of information on most functions of OpenCV.
Hope this helps.
Good luck.
Your question is very similar to this question, which has answers with code examples. Alternatively check the documentation of OpenCV. If you are interested in the convex hull of your points, see cv::convexHull().

Kmeans for image clustering

I am new to image processing and I am using k-means for clustering for my assignment. I am having an issue where my friend told me that to use k-mean in opencv, we need to only pass the color of the object of interest and not the whole image.
This has confused me as I am not sure how to obtain the color composition before apply kmeans. Sorry about my English, I would give an example. I have a picture with several colors and lets say I want to obtain the blue cluster which is a car. So does it means that I need to pass only the color blue to the kmeans.
Maybe I am totally wrong in this since I am unsure and i have been struggling for several days now. I think I need thorough explanation from some expert whom i think i will get it here.
Thank you for your time.
In order to put you in the right direction, below are some hints:
you will pass all the pixels to k-means alongwith the desired number of clusters (or groups) to find
k-means will process you data and will cluster you data in the specified number of clusters
you will take the pixels in blue cluster (e.g.) to do what you want to do.
I hope this will help ;)

Image Processing - Which OpenCV algorithm will fit my needs?

I started to work on a small hobbyist program recently in the area of image processing, and I'm kind of a noob with image processing but I'm trying to figure out at least some aspects of it.
What I want to be able to do is separate between objects in an image by their color (preferably in a real-time video feed), and then recognize their color.
I read a little about OpenCV and also about some of the different algorithms.
I even started to work a little with the canny algorithm, but I'm not sure this is the algorithm I should begin with for my need, as it detects edges of objects regardless of their color.
Even if it is the algorithm I should use, what would be the best method to recognize the colors of the objects it marked for me?
I hope I made myself clear enough.
Thanks a lot!
Understand colour spaces - RGB is almost always the worst source to do image processing on.
Start with HSL and HSV
To separate or to make a color transparent (for instance to remove it) is very simple with OpenCV... I posted an answer (see the link below) which should help you (or maybe solve your problem).
Here is the code I posted
Moreover, the answer from Martin Beckett is absolutely right, RGB is not a good color space to evaluate a color, you can use HSV, the hue value in degree tells you the proper color (something you could compare from a wavelength in a light spectrum) while S and V code a sort of intensity (what I say is to simplify in order to explain that in many cases to use Hue to segment color images is enough).
Even if it is the algorithm I should use, what would be the best
method to recognize the colors of the objects it marked for me?
The type of algorithm you are searching for is called color segmentation... Here is a tutorial which could help you as well.
Welcome to image processing community,
Julien,
For starter you should learn about image array operation, for example using OpenCV function inRange to filter colors by minimum to maximum color range. Another option is by splitting multi-channel array (in this case R, G and B) to 3 different single-channel for further examination. Hope its help

Resources