How to extract HSV histogram from image. [EmguCV]

1k views Asked by At

I am making a project where I want to re-identify person based on their soft features like cloth color. So I want to get the HSV and RGB histogram of their images and compare it later to check if it is the same person.

Code i made so far:

//This is small part of the project
        float[] hueHists=new float[255];
        float[] satHists = new float[255];


        DenseHistogram dh = new DenseHistogram(255, new RangeF(0, 255));
        DenseHistogram dh2 = new DenseHistogram(255,new RangeF(0, 255));
        Image<Hsv, byte> hsvImage = image.Convert<Hsv, byte>();

        for (int i = 0; i < 8; i++)
        {
            hsvImage.ROI = new Rectangle(0, i * 16, 64, 16);

            Image<Gray, byte>[] channels = hsvImage.Copy().Split();
            Image<Gray, byte> hue = channels[0];  
            Image<Gray, byte> sat = channels[1];  


            dh.Calculate<byte>(new Image<Gray, byte>[] { hue }, true, null);
            dh2.Calculate<byte>(new Image<Gray, byte>[] { sat }, true, null);

            float[] huehist = dh.GetBinValues();
            float[] sathist = dh2.GetBinValues();

            if(i==0)
            {
                huehist.CopyTo(hueHists,0);
                sathist.CopyTo(satHists,0);
            }
            else
            {
                hueHists = hueHists.Concat<float>(huehist).ToArray<float>();
                satHists = satHists.Concat<float>(sathist).ToArray<float>();
            }

        }

And also should I extract HSV and RGB histogram of complete image or extract after segmentation of image.

[Edit] I have extracted the histogram of a personA and matched it against other people's histogram (to check if he/she is personA or not). Problem the problem is with accuracy. my program can not correctly find same person. And I want to ask the better way to do it...

Help from opencv person is also appreciated

Thanks in advance.

0

There are 0 answers