Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Dominant color and color mask

Hello,

 

try something like this (attachment).

 

One thing I noticed though - and this can give you really erroneus results: though the values of centroids when running the code more than once are the same, their positions shift. To see what I mean, try running  the code once and make a print screen of the centroid values (matrix output from kmeans). Then run the code again and see that the values are basically the same, just disordered. This can give you completly false color.

 

If you can find the solution for this, I think this could solve your problems!

 

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 11 of 18
(2,272 Views)

Hi Klemen,

                If i run the source code more than once,the centroid values for class 1 remains the same,but for class 2,3 and 4 it's changing.Any solution for this?

 

Thank you

MADHUBALAN

0 Kudos
Message 12 of 18
(2,263 Views)

Hello,

 

yes I was just saying that in the previous post. To my knowleddge, clustering is based on taking some random samples in the first step. So it is understandable that the values get reordered after running the algorithm more than once.

 

Try to tako a look at the code of the clustering algorithm; particulary the "Initial In" - these are the initial centroids. Maybe this could help you.

 

 

Or maybe perform clustering on the RGB image directly?

 

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 13 of 18
(2,255 Views)

Hi Klemen,

                In the color mask.vi file,you have used IMAQ extract 2,i dont have it in my library,when i asked you whether can i use IMAQ extract,you said i can use it,but getting a wire loose end.i.e, when i am wiring between APPENDED ARRAY of  Bulid array and Y-STEP SIZE of IMAQ Ectract,it is not getting wired,can you please send me the IMAQ Extract2.

 

I have attached the image file..

 

Thank you

MADHUBALN

0 Kudos
Message 14 of 18
(2,241 Views)

Hello,

 

leave "step size" unwired and wire the array to "optional rectangle". This specifies the extracted region. X step and Y step specify reduction ratio and you don't need this. Leave it unwired (default = 1).

 

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 15 of 18
(2,233 Views)

Hi Klemen,

                 In this dominant color k-means clustering - Kopie (1).vi file,how to determine the percentage of color in each classes? and also how to use a different image as input in the color mask1.vi file.

 

 

THank you

MADHUBALAN 

 

0 Kudos
Message 16 of 18
(2,225 Views)

Hello,

 

please explain what do you mean by percentage of colors? What do you want to achieve. As I stated before, the problem is in that although the clustering works very good, the centroids of individual color planes are not "aligned". So you get different colors everytime, although the numbers (if put in them the right order) produce the correct dominant colors. Have you tried clustering on RGB image directly?

 

To change the input image replace as shown below:

NIVISION.png

 

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 17 of 18
(2,213 Views)

Hi Klemen,

                I had attached a image file of regarding color percentage of dominant color k-means clustering - Kopie (1).vi file. In the image file the first dominant colror is red,i would like to know how percentage of color(red)present in the given input image, likewise i would like to find the percentage of remaning color in the input image.

For e.g.red(70%)pink(2%),yellow(4%).

 

Thank you

Madhubalan 

0 Kudos
Message 18 of 18
(2,206 Views)