0
votes

I need help for 1-level 5/3 discrete Haar wavelet transform (DWT) source code with c# .

I use this project, and the methods of forward wavelet transform is here :

FWT(double[] data)
    {
        int h = data.Length >> 1;
        for (int i = 0; i < h; i++)
        {
            int k = (i << 1);
            temp[i] = data[k] * s0 + data[k + 1] * s1;
            temp[i + h] = data[k] * w0 + data[k + 1] * w1;
        }
    }
FWT(double[,] data)
{
for (int k = 0; k < 1; k++)
{
    for (int i = 0; i < rows / (k+1); i++)
    {
        for (int j = 0; j < row.Length / (k+1); j++)
            row[j] = data[i, j];

        FWT(row);

        for (int j = 0; j < row.Length / (k+1); j++)
            data[i, j] = row[j];
    }

    for (int j = 0; j < cols / (k+1); j++)
    {
        for (int i = 0; i < col.Length / (k+1); i++)
            col[i] = data[i, j];

        FWT(col);

        for (int i = 0; i < col.Length / (k+1); i++)
            data[i, j] = col[i];
    }
}

}

w0 = 0.5; w1 = -0.5;s0 = 0.5;s1 = 0.5;

I searched about this topic in the papers , but I don't understand the algorithm of 5/3 or 9/7 wavelet filters and how can I change this code? Any help would be much appreciated

1

1 Answers

0
votes

You may find it useful: implementation of jpeg2000 decoder in pdf.js.

The implementation of the core of the 5-3 code:

function reversibleTransformFilter(x, offset, length) {
    var len = length >> 1;
    offset = offset | 0;
    var j, n;

    for (j = offset, n = len + 1; n--; j += 2) {
        x[j] -= (x[j - 1] + x[j + 1] + 2) >> 2;
    }

    for (j = offset + 1, n = len; n--; j += 2) {
        x[j] += (x[j - 1] + x[j + 1]) >> 1;
    }
};