2

我想从仅从最大系数的 5% 的多级 DWT 变换中重建图像,同时将其余系数设置为零。我不确定我需要从哪些系数中选择最大的 5%?A、H、V 还是 D?

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

% Read image
x = imread('app.bmp'); 

% Define wavelet name
wavelet = 'haar';
% Define wavelet decomposition level
level = 4;
% Define colormap
map = gray;
% Compute multilevel 2D wavelet decomposition
[C, S] = wavedec2(x,level,wavelet);
for i = 1:levle
    % Approximation coefficients
    A = appcoef2(C,S,'haar',i);
    % Detailed coefficients
    [H,V,D] = detcoef2('all',C,S,i);
 end

任何帮助,将不胜感激!

4

1 回答 1

0

为了获取矩阵/向量的最高 x% 值,我通常这样做:

% define the threshold (5% here)
thr = 0.05;
% sort the variable in descending order
As = sort(A(:),'descend');
% obtain the elements belonging to the top x%
At = As(1:ceil(numel(As) * thr));

现在 At 变量包含矩阵/向量 A 的前 x% 值。由于您希望保持 A 的原始形状并将其所有低于阈值的元素设置为 0:

% take the minimum value of the result
Am = min(At);
% take the original matrix and set all the elements below the minimum top x% to zero:
A(A < Am) = 0;

在这里你得到你的 A 矩阵/向量的最终形式。

于 2017-11-28T07:47:55.057 回答