clcrutch
clcrutch

Reputation: 61

Find the Most Prominent Color From an Image Using Emgu CV

So, I have this image of a face: https://i.sstatic.net/gsZnh.jpg and I need to be able to determine the most dominate/prominent RGB and The YCrCB value from it using Emgu CV. Thank you for the help.

Upvotes: 1

Views: 2690

Answers (2)

Cagan Arslan
Cagan Arslan

Reputation: 130

You should first get the histogram of every color channel. Then you can use minmax function to get the most dominant color.

The code I'm posting is for an HSV image, you can change channel names for your color space.

  Image<Gray, Byte>[] channels = hsv1.Split();
                Image<Gray, Byte> ImgHue = channels[0];
                Image<Gray, Byte> ImgSat = channels[1];
                Image<Gray, Byte> ImgVal = channels[2];

 DenseHistogram histo1 = new DenseHistogram(255, new RangeF(0, 255));

 histo1.Calculate<byte>(new Image<Gray, byte>[] { ImgHue }, true, null);

  float minV, maxV;
        int[] minL;
        int[] maxL;


 histo1.MinMax(out minV, out  maxV, out minL, out maxL);


 string mystr = Convert.ToString(maxL[0]);
                label1.Text = "Hue= " + mystr; 

You can do the same thing for Saturation and Value channels too.

Upvotes: 1

ARM7
ARM7

Reputation: 11

You can use histogram to find the distribution of colors and choose the highest value as the dominant color. Don't know about related functions in Emgu CV though for now. Good Luck

Upvotes: 0

Related Questions