我需要c#帮助1级5/3离散Haar小波变换(DWT)源代码。
我用这个项目,小波前向变换的方法在这里:
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; s1 = 0.5;
我在论文中搜索了这个主题,但我不理解5/3或9/7小波滤波器的算法,我怎么能改变这个代码?如有任何帮助,不胜感激
您可能会发现它很有用:在pdf.js中实现jpeg2000解码器。
实现核心的5-3代码:
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;
}
};