From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Color identification in an image (not shape)

Solved!
Go to solution

Hello to all.

First of all thanks a lot for reading this post and being able to help.

 

I would like to do the next:

  • I have an image like this:

image.png

 

  • I would like to identify all shapes (circular, square, triangular...) (big one, small one...) that have orange color and his position in the image. So in this case, the result would be 5 orange figures.

I think I must have a template wich is going to be the color (in this case orange). And with options I can specify the intensity color or something like that for algorithm recognition.

 

Is there any function in vision labview to do this?

Any ideas?

 

I just need a tip and then work on it.

 

Thanks a lot.

 

 

 

0 Kudos
Message 1 of 6
(2,901 Views)

Convert the image to HSL (or any H**), and use the Hue channel. Do a simple threshold on the Hue of orange +/- a margin, and only orange objects are selected.

0 Kudos
Message 2 of 6
(2,878 Views)

Are there going to be many colors to pick from? A color classifier might be a choice.

 

Check out the Color Classification example in the Example Finder. If that looks like it would work, there's a Vision Color Classification Training program that you can use to create a new classifier and add examples of all the colors you're looking for.

 

I think finding the shapes and identifying its colors would be easiest done in two stages. First process to find all the particles in your image. Look up the examples for thresholding, segmentation, labelling, and binary particle analysis report if you need some ideas. The iterate through and identify the color of each of the particles.

0 Kudos
Message 3 of 6
(2,849 Views)

Hello,

Thanks for replying.

 

There are going to be two or three color properly. but for example, for one color There could be many intensities.

 

In the second option that you mentioned about first get the shape and then get the color I think it is complicated in this case for the next reason:

The image could be like this:

image.png

 

So, the shape that it is in red circle. I would like to count the orange part (1 in image) if this part has more than 100 pixels for example. If this part is less than 100 pixels not count.

 

Could I do that?

0 Kudos
Message 4 of 6
(2,771 Views)

Thanks a lot for replying.

I did an example with HSL and it works (I have to improve the example), but now I would like to do what I post above.

 

Could you help me?

 

Thanks a lot.

0 Kudos
Message 5 of 6
(2,769 Views)
Solution
Accepted by topic author Alvaro.S

@Alvaro.S wrote:

Thanks a lot for replying.

I did an example with HSL and it works (I have to improve the example), but now I would like to do what I post above.

 

Could you help me?

 

Thanks a lot.


Colors aren't exactly defined. So how do you want to "count colors"?

 

You should be able to get all the pixels (in RGB and\or HSL) as a 1D or 2D array. Than you can do with them what you want in plain LV. I'd guess a histogram could be useful.

 

Keep in mind that H is a 'continuous' scale, wrapping around it's maximum. So you should support ranges from 10-30, but also from 250-15 (from 250-255 and from 0-15).

0 Kudos
Message 6 of 6
(2,728 Views)