1

このペーパーで説明されているように、ガボールウェーブレット機能を実装しようとしています: 「画像データの参照と取得のためのテクスチャ機能」

特徴ベクトルは平均値と標準偏差から構成されます (以下の特徴ベクトルの例は、スケール = 4 と方向 = 6 です)

ここに画像の説明を入力

実装コード:

void gabor_main(int argc, char **argv)
{
    int img_height;             // height of input image
    int img_width;              // width of input image
    int side;                   // side (filter dimension = (2*side+1)*(2*side+1)) = 60
    int scale;                  // number of scale
    int orientation;            // number of orientation
    int flag;                   // flag (removing the DC term) = 0 (False)

    FILE* fp;
    unsigned char *tmp_raw_img; // temporary raw image data
    double Ul;                  // Uh (highest spatial frequency)
    double Uh;                  // Ul (lowest spatial frequency)

    Matrix* img_mat;            // input image
    Matrix* F_r;                // result, real part
    Matrix* F_i;                // result, imaginary part
    Matrix* F_m;                // result, magnitude of real part and imaginary part

    scale = 4;
    orientation = 6;
    Ul = 0.1;
    Uh = 0.4;
    flag = 0;
    side = 60;


    ...


    /* ----------------- Reading raw image ----------------- */


    ...


    /* ----------------- Gabor filtered outputs ----------------- */
    CreateMatrix(&F_r, img_height * scale, img_width * orientation); // memory allocation of real part matrix of the output 
    CreateMatrix(&F_i, img_height * scale, img_width * orientation); // memory allocation of imaginary part matrix of the output
    CreateMatrix(&F_m, img_height * scale, img_width * orientation); // // memory allocation of magnitude of the output

    GaborFilteredImg(F_r, F_i, img_mat, side, Ul, Uh, scale, orientation, flag);


    /* ----------------- Compute Feature Vector ----------------- */
    // Magnitude of complex value
    for (int h = 0; h < (img_height * scale); h++)
    {
        for (int w = 0; w < (img_width * orientation); w++)
        {
            F_m->data[h][w] = sqrt(F_r->data[h][w] * F_r->data[h][w] + F_i->data[h][w] * F_i->data[h][w]);
        }
    }

    for(int i = 0; i < scale; i++)
    {
        for(int j = 0;j < orientation; j++)
        {
            double avg = Average(F_m, img_height, img_width, i, j);
            double std = StandardDeviation(F_m, img_height, img_width, i, j);

            // Print the result
            std::cout << avg << " " << std << "\n";
        }
    }    

    FreeMatrix(F_r);
    FreeMatrix(F_i);
    FreeMatrix(F_m);
}

平均および標準偏差のコード:

double Average(Matrix* F_m, int img_height, int img_width, int scale, int orientation)
{
    double avg = 0.0;

    for (int h = (img_height * scale); h < (img_height * (scale + 1)); h++)
    {
        for (int w = (img_width * orientation); w < (img_width * (orientation + 1)); w++)
        {
            avg += F_m->data[h][w];
        }
    }
    avg /= (img_height * img_width);

    return avg;
}

double StandardDeviation(Matrix* F_m, int img_height, int img_width, int scale, int orientation)
{
    double std = 0.0;
    double avg = Average(F_m, img_height, img_width, scale, orientation);

    for (int h = (img_height * scale); h < (img_height * (scale + 1)); h++)
    {
        for (int w = (img_width * orientation); w < (img_width * (orientation + 1)); w++)
        {
            double dif = F_m->data[h][w] - avg;
            std += (dif * dif);
        }
    }
    std = sqrt(std / (img_height * img_width));

    return std;
}

注:GaborFilteredImgの関数のコードは、このhttp://vision.ece.ucsb.edu/texture/software/gabor.cからコピーしました

私が書いたコード (「Compute Texture Feature」セクションから始まる) が正しいかどうかを尋ねたいと思います。出力 F_r (実部) と F_i (虚部) を指定して平均値と標準値を取得するかどうかはわかりません。基本的に、ガボールフィルターバンクのすべての応答の平均と標準を計算します

===更新===

ここに画像の説明を入力

これらの F_r と F_i は、scale=4 と orientation=6 を使用したガボール フィルタリングの結果です。F_r と F_i はどちらも次元 (img_height * scale) * (img_width * orientation) を持ち、基本的にガボール フィルター バンクの各応答のグリッドで構成されます。

次に、大きさを計算します F_m(x,y) = sqrt(F_r(x, y) * F_r(x, y) + F_i(x, y) * F_i(x, y))

最後に、F_mの平均と標準偏差である特徴ベクトルを計算します

===画像===

画像入力(リアル):http: //goo.gl/kc5BG

ガボール銀行 (リアル) : http://goo.gl/0qM4E

ガボール銀行 (仮想) : http://goo.gl/r7Fnk

出力 (リアル) : http://goo.gl/nxVMn

出力 (虚数) : http://goo.gl/SnD7p

4

0 に答える 0