I am going to apply a HSV threshold to the image below in order to extract the tennis ball. But I could not figure out the best way to find the correct HSV values of the ball. Which method/software do you suggest to me? (I am using Ubuntu) Also according to your experiences which min/max values do you prefer to me? (±10? ±5?)
Regards
You can use Gimp to get needed color. The tool is called Color Picker. It also shows HSV values. Here's screenshot of your image:
Have you considered to use Hough CircleDoc ?
I think in this case it would be much more indicted, because the colors in your image aren't so clear
Related
We have an RGB image. I want to apply adaptive thresholding on it. How can we find the threshold value??? I think we can separately find the threshold value of each channel but what next is the confusion?? or if you can provide some better solution it would be appreciable. Thanks.
You wrote that you want to apply thresholding so I assume that you want binarized image as output. Is there any special reason that you want perform thresholding on each channel separately? If not, try convert image to grayscale and then apply thresholding. If you want you could apply thresholding on each channel separately and then merge output binarized images from each channel into one output but I don't know why you wan to do it.
So I have an image that has some dark spots, and they look pretty simple so I think I can creaat an luminance map, invert it and then apply it to my image to undo the dark spots. However all I can find is two methods for equalizing: equalize whole image(with histogram) or segment the image in dark meddium and light parts and equalize which you want. The first approach does not help my problem and the second approach also makes the dark objects in the image lighter. I am sure there is an easy way to do this (long ago I saw somebody do it in a presentation), although I havent been able to find it or come up with it yet.
So my question: how would I create a "luminance map" of an image like this:
So I get a map like this:
Which I can apply inversely to get a better image like this:
I understand I will have discretization errors at the corrected spots, but thats much better than the dark spots. I hope someone can help me do this, thanks!
I mainly use Matlab and have some limited python and mathematica knowledge, but a Matlab example would be most useful to me. One way I thought of myself was taking fft2 and nulling the low frequencies, but that would just destroy all contrast, not just the partss I want.
Similar but different SO questions that did not help me:
Image equalisation
thresholding an image based on gradient
Histogram of image
Matlab - Local Histogram Equalization
How to find out light, medium and dark color?
You will have to very precisely model the nature of the dark spots for this process to work. Can you characterize whether the dark gradient is linear, exponential, power, trigonometric, or some other predictable function? Is it always exactly circular?
Having straight-line elements in the photo helps, and may provide a source of samples to calculate the nature of the dark spot from. If you treat the dark spot like a quadratic or cubic function in three dimensions (X, Y, luminance) then you can solve it based on a certain number of known points.
I can't find the best way to detect red color in different illumination or background.
I found that there's YCbCr color space which is good for red or blue color detection (actually I need to detect blue color too). The problem is that I can't figure out which threshold to use in different lightning. For example in sunny weather this threshold equals 210 (from 255), when in cloudly weather this threshold equals 130.
I use OpenCV library to implement this.
Thanks for any help or advice.
Yes, HSV is usually used for such purpose. In HSV you can tell that whatever is brightness etc, red is what is needed. I also recommend to look into two places. One is simple tutorial http://aishack.in/tutorials/tracking-colored-objects-in-opencv/ and another is to take a book Learning OpenCV and use examples of histograms from there. They do exactly what you need. Using HSV and Histograms makes your solution solid.
HSV color space should be more robust to change of illumination.
Using opencv, can a detection of a certain colour(Between a certain range of rgb values) be carried out in an image or a video frame?
You need to the define the treshold in RGB, and process the pixels in the image (hopefully not the whole image but a smaller region of interest, maybe a moving foreground shape) that fit to the deffinition. Something similar to what is discussed here.
I am understanding that you know the color(or colors) you want to detect a priori.
I hope this helps.
Yes, better convert the image to HSV and try the 'InRangeS' function. Here is an example to track two different colors at same time:
https://github.com/abidrahmank/OpenCV-Python/blob/master/Other_Examples/multi_color_two_object.py
Hope it helps.
Yes - but it's easier in HSV color space. Tutorials here
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