獲取圖像頻域並分解為高低頻(MATLAB)


獲取圖像頻域並分解為高低頻(MATLAB)

我們展示兩種頻域分解方案: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])


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM