Ask Your Question
0

Feature extracting for color

asked 2016-08-15 04:52:57 -0600

damiya14 gravatar image

I am trying a color recognition system with the use of machine learning. I have read some papers. They are several feature extracting methods. What is the best feature extracting method for color recognition system?

edit retag flag offensive close merge delete

Comments

1

Well basically you want to convert your image to a color space that is most suitable of retrieving your color. Then use thresholds on the different channels to segment out a specific color range. HSV color space is one of the most frequently used ones for this purpose!

StevenPuttemans gravatar imageStevenPuttemans ( 2016-08-16 08:08:59 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
2

answered 2016-08-18 01:35:38 -0600

berak gravatar image

updated 2016-08-18 01:36:52 -0600

since any color space on its own has some problems (bgr with intensity, hsv with "non-colors" like black/white/silver), i'd suggest stacking up several colorspaces into a feature vector, in the hope, that one space compensates errors of the other.

Mat feature(const Vec3b &pixel) {
    // normalized bgr;
    float b = float(pixel[0]) / 255;
    float g = float(pixel[1]) / 255;
    float r = float(pixel[2]) / 255;

    // ycrcb
    float y  = 0.299f * r + 0.587f * g + 0.114f * b;
    float cr = 0.713f * (r - y) + 0.5f;
    float cb = 0.564f * (b - y) + 0.5f;

    // hsv
    float M(max(max(b,g),r));
    float m(min(min(b,g),r));
    float md = M - m;
    float A = 1.0f / 6;
    float v =  M;
    float s = (M>0)   ? (md/M) : 0;
    float h = (md==0) ? 0 :
              (M==r)  ? (    A*(g-b)/md) :
              (M==g)  ? (2*A+A*(b-r)/md) :
                        (3*A+A*(r-g)/md);

    return Mat_<float>(1,9) << b,g,r, y,cr,cb, h,s,v; // 9x1
}

trying with skin/noskin data, and a linear svm:

// train data:
7990 positive, 19000 negative probes, [9 x 26990] feature elems.
// test data:
1000 positive, 1000 negative probes, [9 x 2000] query elems.
// confusion
[949, 0;
 51, 1000]
1949/2000 : correct, 0.9745 accuracy.
edit flag offensive delete link more

Comments

2

thanks a lot

damiya14 gravatar imagedamiya14 ( 2016-08-18 01:44:13 -0600 )edit

hey quick question.

what do you mean by trying with skin/noskin data (skin/noskin mean?)

Thanks :)

damiya14 gravatar imagedamiya14 ( 2016-09-06 12:24:08 -0600 )edit

and whats the value of "f" or what does it do in the code?

Thank you

damiya14 gravatar imagedamiya14 ( 2016-09-26 02:16:18 -0600 )edit
1

do you mean, like in 0.2f ? it just denotes, that you want a float number here, not a double.

berak gravatar imageberak ( 2016-09-26 02:19:37 -0600 )edit

Thank you. and another question

  1. As mentioned in this link it says when Cmax=r ther is something calle mod6 in that condition.

    But in this code mod6 is not there.

    What is it? Does it matter to this code?

  2. Why do you use A = 1.0f/6 ? Not as 60?
damiya14 gravatar imagedamiya14 ( 2016-09-26 02:44:32 -0600 )edit
1
  1. idk. it's more or less the formula from the opencv docs.
  2. because hue is in [0..1] range. 60 would be the right thing, if it was [0..360]
berak gravatar imageberak ( 2016-09-26 03:14:52 -0600 )edit

Oh got it. Thanks a lot!!!

damiya14 gravatar imagedamiya14 ( 2016-09-26 03:22:28 -0600 )edit

and for this color you are getting an average value or or all the pixels color?

damiya14 gravatar imagedamiya14 ( 2016-09-28 02:31:58 -0600 )edit

^^ sorry, but i don't get what you mean (what is "this color" ?)

berak gravatar imageberak ( 2016-09-28 02:34:03 -0600 )edit

i mean in this part,

float b = float(pixel[0]) / 255;
float g = float(pixel[1]) / 255;
float r = float(pixel[2]) / 255;

do i have to consider all the pixels or just get and average for the image?

damiya14 gravatar imagedamiya14 ( 2016-09-30 02:16:39 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-08-15 04:52:57 -0600

Seen: 293 times

Last updated: Aug 18 '16