LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Identifying three different colors within a single image

Hello everyone,

I recently begun a project which requires me to process the image from a USB camera, and could use some assistance.

Once I get the image I need to determine the center of mass for three different colors within this image. Although this seems to be a relatively straight forward task I ran into a roadblock right off the back.

This roadblock relates to how to properly isolate each of the colors from the image without using too much memory. My original structure had the USB image coming in, and then I would process that image for the three different colors. Unfortunately, this required using a total of four instances of IMAQ create. (One for the acquisition, and three for all of the color threshold images). Although this works it seems a bit inefficient.  Allocating memory for 4 RGB U32 images uses a lot of memory!

Visual snippet attached below for aiding explanation

So in a nut shell, I’m wondering if there is any way to improve this, and decrease memory usage. My First thought was to only use two IMAQ create (one for acquisition and one for processing) then, iteratively (for loop, or something of that nature) run the processing image through a processing loop with different threshold parameters for each iteration.  My worry is that this will significantly add to the latency of my program.

Are there any others ways to do this that I am missing, or am I on the right track? If you have any suggestions they would be much appreciated.

Thanks,
Taylor S. Amarel

Learning is living.
Co-Founder and CEO of http://3dprintingmodel.com/

"If we did all the things we are capable of, we would literally astound ourselves."
-Thomas Edison
0 Kudos
Message 1 of 5
(2,945 Views)

Hello,

 

Out of curiosity, does you application do something like this? 

 

Counting Particles or Cells Using IMAQ Vision

Counting Particles or Cells Using IMAQ Vision

http://zone.ni.com/devzone/cda/tut/p/id/3169

 

This example discussed techniques for identifying thresholds that may be implemented in a different manner than your program. Please let me know if this is heading int he right direction; otherwise, we can revisit additional resources. 

 

Thank You, 

 

Patrick Corcoran
Application Engineering Specialist | Control
National Instruments

0 Kudos
Message 2 of 5
(2,896 Views)

Patrick,

The example you linked does have some characteristics of the system I wish to create. Unfortunately the example does not go into much detail about "labeling particles" by their color value. I have a strong understanding of how image particle analysis works. But fall short when is comes to the most efficient way of doing this. This is more of a optimization question, rather than a image analysis query. 

Here is an explanation of what I'm trying to do.
In plain English, I want to input an image and find the center of mass of three color, or color ranges.

Suppose I had this image;

21624i60D912154A80651D

 

And I want to calculate the center of mass for the Red, Green, and Blue disks. I also need to differentiate the different center of masses. Red_Center(x,y), Green_Center(x,y), Blue_Center(x,y). In a nutshell, Input Image >> Output Three Coordinates.

What I'm trying to figure out is the quickest and most effective way of calculating these values with minimum memory usage. As stated earlier if I process the image for Red, Green, and Blue centers in parallel it would require allocating an image location for each color. This would cause an enormous memory overhead. (1600 X 1200 X 32 bit X 3) Far too much!!!

So I'm looking at a way of accomplishing this without stretching my memory resources dry. I thought that if I put the processing in a For Loop and input an array of Threshold values. (Red, Blue, Green), (1D X 3) then it would process Red, and begin autoindexing the centers. Then it would it would iterate again and process Blue, and likewise index the centers of mass...

Is this the right way to do that, I am a self taught LabVIEW enthusiast so I do not have much experience when it come to building complex applications that require explicit memory management.

Thanks,
Taylor S. Amarel

Learning is living.
Co-Founder and CEO of http://3dprintingmodel.com/

"If we did all the things we are capable of, we would literally astound ourselves."
-Thomas Edison
0 Kudos
Message 3 of 5
(2,883 Views)

There is a fair amount of grayspace when we talk about 'right' and 'wrong.' I believe the iterative method of manipulating the color arrays is a very effective path forward. Inevitably, you will need to determine if the solution is 'right,' as you must make a determination if the program successfully completes the task within the constraints you have defined. 

 

Moving from the parallel 32-bit images to iterated 1D arrays, should significantly reduce the memory usage of the code.

 

Cheers! 

0 Kudos
Message 4 of 5
(2,863 Views)

Thanks, that was a great help.

My application does not necessarily need to complete this calculation very fast. But it does need to use very little memory.

I'll post back my results.

Once again thanks,
Have a good day.

Learning is living.
Co-Founder and CEO of http://3dprintingmodel.com/

"If we did all the things we are capable of, we would literally astound ourselves."
-Thomas Edison
0 Kudos
Message 5 of 5
(2,856 Views)