How to count number of hues in an image?
    5 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
Hello all,
I would like to do a hue count in an image; what I want to do is to differentiate between images with a large number of hues and images with just a few hues.
Do you have any advice on that?
I did this (M is mask, I dont want to include pixels with low/high hue values and low saturation):
M = Ihsv(:,:,2)>0.2 .* (Ihsv(:,:,3)>0.15 .* Ihsv(:,:,3)<0.95);
Tmasktrue = I(find(M));
Tmasktrue=double(Tmasktrue);
[nr,xout] = hist(Tmasktrue, 20);
hue_count= std2(nr);
If in histogram with 20 bins I have all bins equally filed with pixels, std2 will be 0; if I have all pixels in only one bin, I will have std2 very large.
Please check and comment my code, regards, M.
0 Commenti
Risposte (2)
  Walter Roberson
      
      
 il 15 Mar 2013
        To count the number of hues, you should use
hue_count = length(unique(I(M)));
  Image Analyst
      
      
 il 15 Mar 2013
        The total number of hues is as Walter said. If you want to take a histogram into a different number of hues, and get the count for each range, you can do that
[hueCount, hueValues] = hist(M(:), numberOfBins);
2 Commenti
  Image Analyst
      
      
 il 15 Mar 2013
				You could do that, if you want to identify images that span the gamut fairly evenly. Of course you could also do that directly on the Tmasktrue image directly and not bother with a histogram, you'd just look for high std dev instead of low std dev.
Vedere anche
Categorie
				Scopri di più su Histograms in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!