LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to fellow a moving ROI in a movie defined by pixels in a range of color ?

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

0 Kudos
Message 1 of 7
(3,497 Views)

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. 

 

Color Threshold

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.

Color Classification

Use this function to classify samples in an image based on their color.

Color Matching

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.

Color Location

Use this function to locate regions in an image that contain a specified color. This function does not modify the image.

Matthew Fitzsimons

Certified LabVIEW Architect
LabVIEW 6.1 ... 2013, LVOOP, GOOP, TestStand, DAQ, and Vison
0 Kudos
Message 2 of 7
(3,473 Views)

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....

Download All
0 Kudos
Message 3 of 7
(3,464 Views)

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.  

Matthew Fitzsimons

Certified LabVIEW Architect
LabVIEW 6.1 ... 2013, LVOOP, GOOP, TestStand, DAQ, and Vison
0 Kudos
Message 4 of 7
(3,457 Views)

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.

Matthew Fitzsimons

Certified LabVIEW Architect
LabVIEW 6.1 ... 2013, LVOOP, GOOP, TestStand, DAQ, and Vison
Message 5 of 7
(3,455 Views)

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:

 

CenterOfMass.png

 

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.

 

 

Message 6 of 7
(3,443 Views)

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

Download All
0 Kudos
Message 7 of 7
(3,439 Views)