Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

color pattern matching

Hello smurillo,

 

i think you should have more flexibility if you perform matching on grayscale channel and then extract the color information. You can for example use color classification with geometric pattern matching, since i now see that your object have different sizes. Or if you create a template for each shape and color and use pattern matching. Then you can also use clustering to get the dominant color (since the objects are monocolored, this should work ok) of the matched pattern (there has been some recent discussion about k-means clustering - the code is also attached there). Maybe it would also work to perform color histogram matching for example. Or extract red, green and blue plane and calculate the average pixels value of each plane. There are some ways, but sadly i cannot say which would work. You have to test this.

 

First though, i would try to get the shape matches correctly classified (only shape, so it should find for example three big cubes, so the red, green and the blue) and then the color. Also you need to be careful about the lighting - the big green cube does not look very green).

 

It does not matter where you create the templates. Ni Vision Assistant is easier though.

 

I will take a look and try to help you if i can.

 

Best regards,

K


https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
0 Kudos
Message 11 of 16
(1,573 Views)

Hello,

 

just a small update about my opinion regarding your project. For best results, you should first define your constraints - mainly your lighting conditions. The image you provided has many shadows and some objects don't even have the correct RGB values (i.e., for some objects, the dominant color plane is different as expected). For example: are all blue object the same color, or are some darker blue?

 

I am attaching a really simple example of classification first based on pattern matching and then on color (here i take only one pixel, but you could also take a bigger radius for more roboust color detection). I have created the grayscale templates with Ni Vision Assistant.

 

Are you also planning to correct the lens distortions for your project?

 

Again, I think you should consider a little bit more about your setup and lighting conditions and assure repeatabilty. It would then be easier to process the acquired images.

 

Best regards,

K

 

 

 


https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
0 Kudos
Message 12 of 16
(1,561 Views)

Look at the false positives you have supplied.


There will be a systematic problem with the shapes.

A triangle is always found at the corners of a rectangle, when the triangle is smaller than the rectangle width.

 

To avoid this problem, capture a background image before placing objects on the surface.

detect the rectangles first, and when they are registered, replace the rectangle with the background image. (copy replace)

this will greatly reduce the number of false positives.

 

Then detect the circular shapes, and "remove" them using the same technique.

then the triangles cannot possibly create false positives.

 

for color seperation, try using the HSL space instead of the RGB.

Engineer, M.Sc. Autonomous Systems, Automation and Control of non-linear systems
Project Engineer @ R&D A/S
www.rdas.dk
0 Kudos
Message 13 of 16
(1,530 Views)

Hello!

 

Just an Update. Your help was very useful, I managed to detect shapes and recognize colors successfully with the last VI. The main problem was the ilumination, but i found a way to fix it with a LED lamp.

 

Thanks a lot!!!

Message 14 of 16
(1,500 Views)

Hey, thanks for the update.

 

Happy to see that you achieved better results.

 

Best regards,

K

 

 


https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
0 Kudos
Message 15 of 16
(1,490 Views)

the detection of color can get concirtiendo 8bit image, then color filter, removing particles,

 

finf_color1.png

 

 

 

 

 

 

0 Kudos
Message 16 of 16
(1,443 Views)