summaryrefslogtreecommitdiff
path: root/genFeatureVec.m
blob: d3ee0564580fbf5e0366460533a17bbeee11c55d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
function vec = genFeatureVec(img,minc,maxc)
    bins = 16;
    ncnls = 8;
    secs = 6;
    cnls = zeros(size(img,1), size(img,2),ncnls);
    cnls(:,:,1:3) = img;
    cnls(:,:,4:6) = rgb2ycbcr(img);
    hsv = rgb2hsv(img);
    cnls(:,:,7:8) = hsv(:,:,1:2);
    %for i=1:ncnls
    %    cnls(:,:,i) = histeq(cnls(:,:,i));
    %end
    % Schmid
    scVec=[
        1,2;
        1,4;
        2,4;
        1,6;
        2,6;
        3,6;
        1,8;
        2,8;
        3,8;
        1,10;
        2,10;
        3,10;
        4,10];
    gbVec = [
        0.3,0,4,2;
        0.3,0,8,2;
        0.4,0,4,1;
        0.4,0,8,1;
        0.3,pi/2,4,2;
        0.3,pi/2,8,2;
        0.4,pi/2,4,1;
        0.4,pi/2,8,1;];
    gb = length(gbVec);
    sc = length(scVec);
    vec=[];
    nn=1;
    % Avg
    for cnl = 1:ncnls
        for sec = 1:secs
            pos = maxc(nn);
            neg = minc(nn);
            nn=nn+1;
            ss = (pos-neg)/bins;
            section = getSection(cnls(:,:,cnl),sec,secs);
            v = histcounts(section,(0:bins)*ss+neg);
            v=v/sum(v);
            vec=cat(2,vec,v);
        end
    end
    % Schmid
    for i = 1:sc
        filt = schmidFilter(scVec(i,1),scVec(i,2));
        for sec = 1:secs
            pos = maxc(nn);
            neg = minc(nn);
            nn=nn+1;
            ss = (pos-neg)/bins;
            section = getSection(hsv(:,:,3),sec,secs);
            v = histcounts(imfilter(section, filt, 'symmetric'),(0:bins)*ss+neg);
            v=v/sum(v);
            vec=cat(2,vec,v);
        end
    end
    % Gabor
    for i = 1:gb
        filt = gaborFilter(gbVec(i,1),gbVec(i,2),gbVec(i,3),gbVec(i,4));
        for sec = 1:secs
            pos = maxc(nn);
            neg = minc(nn);
            nn=nn+1;
            ss = (pos-neg)/bins;
            section = getSection(hsv(:,:,3),sec,secs);
            v = histcounts(imfilter(section, filt, 'symmetric'),(0:bins)*ss+neg);
            v=v/sum(v);
            vec=cat(2,vec,v);
        end
    end
end