【问题标题】:Reverse biorthogonal 2.2 wavelet inverse DWT implementation逆双正交2.2小波逆DWT实现
【发布时间】:2020-11-07 19:20:49
【问题描述】:

我有一些图像数据 - 据说 - 使用 MATLAB 的 5/3 Le Gall 整数提升小波变换进行了变换。执行逆 DWT 的实际 Matlab 代码调用以下函数:

liftwave('rbio2.2')

它将 4 个 128x128 矩阵(LL、HL、LH、HH)和小波(在提升方案中称为 LS)作为输入,并返回 252x252 像素的图像。我不知道它是否在进行逆 DWT 之前添加了任何填充,也不知道生成的图像大小对于这种类型的小波是否正常。

我正在寻找在 Matlab 之外实现特定小波逆 DWT。我尝试过 pywavelets,但生成的图像不同(错误)。

谁能推荐一个开源实现?

更新

我发现(其中之一)following implementation of the bior2.2 具有整数到整数映射的小波:

void dwt_cdf53_i_ex_stride_i(
    const int *src_l,
    const int *src_h,
    int *dst,
    int *tmp,
    int N,
    int stride)
{
    assert( N >= 0 && NULL != src_l && NULL != src_h && NULL != dst && NULL != tmp && 0 != stride );

    // fix for small N
    if(N < 2)
        return;

    // copy src into tmp
    dwt_util_memcpy_stride_i(tmp+0, 2*sizeof(int), src_l, stride,  ceil_div2(N));
    dwt_util_memcpy_stride_i(tmp+1, 2*sizeof(int), src_h, stride, floor_div2(N));

    // backward update 1 + backward predict 1
    for(int i=2; i<N-(N&1); i+=2)
        tmp[i] -= ( (tmp[i-1] + tmp[i+1]) + 2 ) >> 2;

    tmp[0] -= (tmp[1] + 1) >> 1;

    if(is_odd(N))
        tmp[N-1] -= (tmp[N-2] + 1) >> 1;
    else
        tmp[N-1] += tmp[N-2];

    for(int i=1; i<N-2+(N&1); i+=2)
        tmp[i] += ( tmp[i-1] + tmp[i+1] ) >> 1;

    // copy tmp into dst
    dwt_util_memcpy_stride_i(dst, stride, tmp, sizeof(int), N);
}

如何改变它来执行反向双正交小波?

【问题讨论】:

  • 在 StackOverflow 上寻求书籍、工具、软件库等推荐的问题被视为 off-topic。此类问题可以在Software Recommendations SE 网站上回答。
  • @rahnema1 我已经改写了我的问题,要求修改特定代码 sn-p 以便它执行 rbio2.2 逆 DWT 而不是 bior2.2。

标签: c matlab wavelet wavelet-transform


【解决方案1】:

反向双正交样条小波(rbio2.2)的逆变换与双正交小波(bior2.2)的正向变换相同。在我的脑海中,使用反向小波的整数到整数逆变换的代码应该是这样的:

void dwt_rcdf53_i_ex_stride_i(
    const int *src_l,
    const int *src_h,
    int *dst,
    int *tmp,
    int N,
    int stride)
{
    assert( N >= 0 && NULL != src_l && NULL != src_h && NULL != dst && NULL != tmp && 0 != stride );

    // fix for small N
    if(N < 2)
        return;

    // copy src into tmp
    dwt_util_memcpy_stride_i(tmp+0, 2*sizeof(int), src_l, stride,  ceil_div2(N));
    dwt_util_memcpy_stride_i(tmp+1, 2*sizeof(int), src_h, stride, floor_div2(N));

    // predict 1 + update 1
    for(int i=1; i<N-2+(N&1); i+=2)
        tmp[i] -= (tmp[i-1] + tmp[i+1]) >> 1;

    if(is_odd(N))
        tmp[N-1] += (tmp[N-2] + 1) >> 1;
    else
        tmp[N-1] -= tmp[N-2];

    tmp[0] += (tmp[1] + 1) >> 1;

    for(int i=2; i<N-(N&1); i+=2)
        tmp[i] += ((tmp[i-1] + tmp[i+1]) + 2) >> 2;

    // copy tmp into dst
    dwt_util_memcpy_stride_i(dst, stride, tmp, sizeof(int), N);
}

【讨论】:

  • 这就是我使用 bior2.2 代码pasteboard.co/JzecRnG.bmp 得到的结果,这就是我使用你的代码得到的结果pasteboard.co/Jzedajs.bmp 你是否认为我错了,图像实际上已转换使用 bior2.2 而不是 rbio2.2?我的问题是我看到了一些原始 Matlab 代码没有的工件。
  • 很难说。通常,libdwt 库与 MATLAB 不兼容。 L 和 H 系数的位置可能不同。此外,内存布局可能会有所不同。您应该使用相同的库分解然后组合图像。
  • 你可以试试这个:/* predict */ for(int i=2; i&lt;N-1; i+=2) tmp[i] -= (tmp[i-1] + tmp[i+1]) &gt;&gt; 1;/* update */ for(int i=1; i&lt;N-1; i+=2) tmp[i] += ((tmp[i-1] + tmp[i+1]) + 2) &gt;&gt; 2; 但我不确定是不是这个问题。
猜你喜欢
  • 1970-01-01
  • 2014-02-20
  • 1970-01-01
  • 2018-03-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多