【问题标题】:how to display multi-level wavedec2 in MATLAB如何在MATLAB中显示多级wavedec2
【发布时间】:2017-11-27 22:29:30
【问题描述】:

计算出图像的4级离散小波变换后,如何在matlab中显示这个多级变换? 以及如何绘制相应 DWT 系数的直方图?

这是我到目前为止所做的:

I = imread('image.png');
N = 4;
[C,S] = wavedec2(im2double(I),N,'haar');
A = appcoef2(C,S,'haar',1);
[H1,V1,D1] = detcoef2('all',C,S,1);
[H2,V2,D2] = detcoef2('all',C,S,2);
[H3,V3,D3] = detcoef2('all',C,S,3);
[H4,V4,D4] = detcoef2('all',C,S,4);

【问题讨论】:

    标签: matlab image-processing dwt wavelet-transform


    【解决方案1】:

    这就是我会做的:

    N = 4;
    
    img = imread('image.png');
    img = im2double(img);
    
    [C,S] = wavedec2(img,N,'haar');
    
    for i = 1:N
        lvl = ['Level ' num2str(i)];
    
        A = appcoef2(C,S,'haar',i);
        [H,V,D] = detcoef2('all',C,S,i);
    
        figure('Name',['Images (' lvl ')']);
        % Eventually, you can define a colormap for your images...
        % colormap(pink(255));
        subplot(2,2,1); imagesc(A);
        title('Approximation')
        subplot(2,2,2); imagesc(H);
        title('Horizontal Detail');
        subplot(2,2,3); imagesc(V);
        title('Vertical Detail');
        subplot(2,2,4); imagesc(D);
        title('Diagonal Detail'); 
        suptitle(lvl);
    
        % tweak the histogram bins as you prefer
        figure('Name',['Histograms (' lvl ')']);
        subplot(2,2,1); hist(A(:),32);
        subplot(2,2,2); hist(H(:),32);
        subplot(2,2,3); hist(V(:),32);
        subplot(2,2,4); hist(D(:),32);
        suptitle(lvl);
    end
    

    实际上,由于我在数字图像处理方面不是很有经验,因此您可以调整我的示例并使其适合您的需求。

    【讨论】:

    • 谢谢,这很有帮助。
    • 你知道是否有一种方法可以将所有级别的所有系数组合起来,以便只得到一个直方图? @Tommaso
    • 在每个循环中,您将当前级别的系数保存到循环之前声明的另一个变量中......然后当您拥有所有直方图时打印直方图。
    • 保存当前关卡的所有系数,你的意思是我把它们加在一起或者相乘或者我应该做什么操作?
    • 将它们附加到变量(元胞数组)。
    猜你喜欢
    • 1970-01-01
    • 2020-04-30
    • 2012-06-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多