01-02-2012 07:00 PM
Hi everybody,
The goal of this project is to localize and fellow a moving colored spot in movies. We are looking at videos of subjects taken from upside them. Let's say to simplify that these subjects have a hat of different colors. Of course, the color of these hats can vary slightly during the capture due to light, shadow etc....Is there a way to creat a mask for a range of color (i.e. orange/red or yellow/green) instead of defining a succession of masks? Also, looking for shape will not work because the hats can have very original shape. The endpoint is to calculate the center of the mask (like a barycenter) using pixel weighted as function of their "proximity" to the centered color in the range....
That make anysens or ring any bell?
Thanks for your times!
Olivier
01-05-2012 11:41 AM
Have you tried all of these options? My first choice would be to color threshold the image and see if you can get a repeatable pattern to match, You can set min / max for RGB values. Give it a try and let me know if it gets you anywhere.
Use this function to isolate color features for analysis and processing or to remove unnecessary features based on their color. The result of this function is a binary image.
Use this function to classify samples in an image based on their color.
Use this function to compare the color content of an image or regions in an image to a template containing reference color information. This function does not modify the image.
Use this function to locate regions in an image that contain a specified color. This function does not modify the image.
01-05-2012 02:28 PM
Thanks for you interest in this post!
It doesn't seem that I have access to these functions from my version. I came with a partial solution to this problem which consist to use a theshold on a color and eclude the possibility to have a grey pixel (R~G~B).
Now, the problem I have is to calculate the centroide that I believed could be easy to identify as the point the closest to all the others (point with minimal distance to the ovther points of the cloud). Unfortunately, the calculation of all these distances takes for ever when processed with multiple loop. Is there any fast function to calculate the center of a could? That will be to replace the script in the VI attached here.
Here are the VIs and a JPEG to illustrate the issue. The goal is to find the center of the red star.
You can compare the conditions
(1) Threshold for red=40 ; threshol grey filter=0.75; grey filter = off;
to
(2) Threshold for red=40 ; threshol grey filter=0.75; grey filter = on;
to
(3) Threshold for red=99 ; threshol grey filter=0.75; grey filter = off;
(2) & (3) give good detection showing that excluding the grey condition is worthy....
but the position of the center identified in the star is not idealy located .... any idea to improve this with a low computing cost would be verymuch appreciated! I'd like to have this system quick enough to work during the video capture (on line).
Thanks,
Olivier
PS: you may need to press twice on calculate to have it updated....not sure why....
01-05-2012 02:40 PM
Now that I see your code I can understand why you can't find it. I use NI Vision that makes this a simple task. I don't have a degree in image processing so not sure what algorithms are best for what you are trying to do. NI Vision is a free 30-day trial if you want to check it out.
01-05-2012 02:48 PM
Looking at your code you may see a significant speed increase if you replace your math script with acutal LabVIEW functions because you can run them in parallel. For example: x=sum(A,1) & y=sum(A,2) can be replaced by an index array and two array sum VIs that can run in parallel.
01-05-2012 06:07 PM
I do not have the vision toolkit, but looking at your MathScript (which I also do not have) it appears that you are estimating the centroid by finding the maximum row and column sum. This will bias the result toward the horizontal line of your star. Instead I would simply find the "Center of Mass" of the red pixels you find. It is simple to do with 2 for loops. Replace your MathScript with this:
As to pressing calculate twice, you should change the Mechanical action to Latching, and move the terminal inside the Value Change event case. In fact, all of the terminals you use inside the case should be pulled inside, otherwise you are using stale values when you press calculate.
01-05-2012 07:29 PM
Thanks a bunch for all your advices!
Here is the modified VI with your suggestions. At this time it does the job I need to move forward.
Thanks again!
O