Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Dominant color and color mask

Hi,

    1. How to find which is the dominant color in an image,which method can be used to find it ?

    2. How to apply color mask to an image?

 

Thank you

Mdhubalan Panneerselvam

0 Kudos
Message 1 of 18
(5,580 Views)

Hello Madhubalan,

 

maybe this can help you get some ideas about finding the dominant color. I am attaching a VI that uses three different methods to determine the dominant color:

 

1. Red or green or blue (only one of the three, no colors in between)

2. Hue based histogram

3. K means clustering based (you need to install the library from clustering)

 

The first method returns only red or green or blue value based on the maximum values of the rgb planes.

The second method uses a hue histogram where the rgb values are recalculated. The problem here is the saturation and luminance - the code takes the mean values of both, so its off sometimes.

The third method produces most acurate results, as far as i have been testing it.

 

If you like, you can test the code, but maybe someone with more experience than me can provide a better solution.

 

Anyway, I hope this helps you to proceed in the right direction. Aslo, sorry for the dirty and unoptimized code.

 

I do not understand what did you mean with the color mask?Could you please explain in more detail?

 

Best regards,

 


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 2 of 18
(5,569 Views)

Hi,

    Thank you for the reply.For color mask,my project is to find the object(screw) from the other objects,i am using the technique from a paper "Fast Object Detection Based on Color Histograms and Local Binary Patterns".In this paper they have to find the printer from other object,i have to find the screw instead of printer.In this paper,they are using few techniques,in which initial step is calculate color mask image show in fig 5.

 

Thank you

Madhubalan

0 Kudos
Message 3 of 18
(5,556 Views)

Hi,

    Thank you for the reply.For color mask,my project is to find the object(screw) from the other objects,i am using the technique from a paper "Fast Object Detection Based on Color Histograms and Local Binary Patterns".In this paper they have to find the printer from other object,i have to find the screw instead of printer.In this paper,they are using few techniques,in which initial step is calculate color mask image show in fig 5.

 

Thank you

Madhubalan

0 Kudos
Message 4 of 18
(5,539 Views)

Hello,

 

I saw the paper. It is an interesting approach.

 

I have been trying to build the same mask, but had no luck. It seems this is out of my scope, and I really have no time now to dive deeper into this.

 

I am attaching 2 vi's which produced the best reults so far. Maybe this could help you a bit. Both use a sliding window to determine the regional "dominant colors" and then compare these to the original image (actually grayscale values) and applying the mask. You can see the "dominant" color inside a sliding window by turning on "draw SW?" boolean.

 

I think you should put some more effort in determining the dominant color.

I am sorry I was unable to help more.

 

Best regards,

 

 


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."
Download All
0 Kudos
Message 5 of 18
(5,520 Views)

Hi,

    Thank you very much for your help. You have used IMAQ Extract2, whether it is similar to IMAQ Extract,if it is not the same,please send me IMAQ Extract2 addon.

 

Regards

MADHUBALAN 

0 Kudos
Message 6 of 18
(5,516 Views)

Hello,

 

just use IMAQ extract.

 

Best regards,

 

 


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 7 of 18
(5,507 Views)

Hi Klemen,

                The Dominant color.vi file that you had sent me gives the output as top most dominant color from an image,using the same source code,how to find(display) the top10 dominant color?

 

 

Thank you

MADHUBALAN

0 Kudos
Message 8 of 18
(5,493 Views)

Hello,

 

try increasing the number of classes (kmeans) and modify the output accordingly.

 

Best regards,


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 9 of 18
(5,491 Views)

Hi Klemen,

                Can please check and tell whether this source code is correct or not,if not can you please make changes to it?.

 

Thank you

MADHUBALAN

0 Kudos
Message 10 of 18
(5,480 Views)