我们展示两种频域分解方案:DCT或SWT变换。代码需要适配。
1. DCT变换
参考
%// Load an image
Orig = im2double((imread("output_HEVC/1_QP22_" + tab(i) + ".png")));
%Orig = rgb2gray(Orig);
%// Transform
Orig_T = dct2(Orig);
%// Split between high- and low-frequency in the spectrum (*)
cutoff = round(0.5 * 256);
High_T = fliplr(tril(fliplr(Orig_T), cutoff));
Low_T = Orig_T - High_T;
%// Transform back
High = idct2(High_T);
Low = idct2(Low_T);
%// Plot results
figure, colormap gray
subplot(3,2,1), imagesc(Orig), title('Original'), axis square, colorbar
subplot(3,2,2), imagesc(log(abs(Orig_T))), title('log(DCT(Original))'), axis square, colorbar
subplot(3,2,3), imagesc(log(abs(Low_T))), title('log(DCT(LF))'), axis square, colorbar
subplot(3,2,4), imagesc(log(abs(High_T))), title('log(DCT(HF))'), axis square, colorbar
subplot(3,2,5), imagesc(Low), title('LF'), axis square, colorbar
subplot(3,2,6), imagesc(High), title('HF'), axis square, colorbar
2. SWT变换
picture1=im2double(imread("output/0_QP22_o6.png"));
[gac,ghc,gvc,gdc]=dwt2(picture1,'haar');
%normalize
ghc_l1=ghc(:,:,:,1);
pp=max(max(max(ghc_l1)));
ghc_l1=ghc_l1-pp;
qq=min(min(min(ghc_l1)));
ghc_l1=ghc_l1./qq;
gac_l1=gac(:,:,:,1);
pp=max(max(max(gac_l1)));
gac_l1=gac_l1-pp;
qq=min(min(min(gac_l1)));
gac_l1=gac_l1./qq;
gvc_l1=gvc(:,:,:,1);
pp=max(max(max(gvc_l1)));
gvc_l1=gvc_l1-pp;
qq=min(min(min(gvc_l1)));
gvc_l1=gvc_l1./qq;
gdc_l1=gdc(:,:,:,1);
pp=max(max(max(gdc_l1)));
gdc_l1=gdc_l1-pp;
qq=min(min(min(gdc_l1)));
gdc_l1=gdc_l1./qq;
% mean(mean(ghc_l1+gvc_l1+gdc_l1))
figure()
histogram(ghc,[-0.15:0.002:0.15])
% set(gca,'YLim',[0 18000])
figure()
histogram(gvc,[-0.08:0.001:0.08])
% set(gca,'YLim',[0 30000])
figure()
histogram(gdc,[-0.06:0.001:0.06])
|
请发表评论