A brief talk on compression perception (14): MATLAB implementation of Fourier matrix and wavelet transform matrix

Source: Internet
Author: User

Main content:

    1. Fourier matrix and its MATLAB implementation
    2. wavelet transform Matrix and its MATLAB implementation
Fourier matrix and its MATLAB implementation

Definition of the Fourier matrix: (Source: http://mathworld.wolfram.com/FourierMatrix.html)

The MATLAB implementation of the Fourier matrix:

Dftmtx (N) is the n-by-n complex matrix of values around  the unit-circle whose inner Product with a column vector  of Length N yields the discrete Fourier transform of the  vector. If X is a column vector of length N, then  dftmtx (N) *x yields the same result as FFT (X);   however,  FFT (X) is more efficient.

The inverse discrete Fourier transform matrix is Conj (DFTMTX (N))/N.

%clc;clear; N= -; X= Randn (N,1);d FT_RESULT1= DFTMTX (N) *X;DFT_RESULT2=FFT (X);% IsEqual = ALL (DFT_RESULT1 = =dft_result2); Err= Norm (Dft_result1 (:)-dft_result2 (:));ifErr <0.01fprintf ('dftmtx (N) *x yields the same result as FFT (X)');Elsefprintf ('dftmtx (N) *x does not yield the same result as FFT (X)'); end
Wavelet transform matrix and its MATLAB implementation

The concept of a wavelet transform matrix:

Reference: http://blog.csdn.net/jbb0523/article/details/42470103

MATLAB implementation of wavelet transform matrix:

function [WW] =dwtmtx (N,wtype,wlev)%dwtmtx discrete wavelet transform matrix%This function generates the transform matrix WW according to input%parameters N,wtype,wlev.%detailed explanation goes here% N isThe dimension of WW% Wtype isThe wavelet type% Wlev isThe number of decomposition level%note:the extension mode must be periodization ('per') [H,g]= Wfilters (Wtype,'D'); %decomposition low&High pass Filterl=length (h); %Filter lengthh_1= FLIPLR (h); %Flip Matrix left to rightg_1=FLIPLR (g); Loop_max=log2 (N); Loop_min=Double(Int8 (log2 (L))) +1;ifwlev>loop_max-loop_min+1fprintf ('\nwaring:wlev is too big\n'); fprintf ('The biggest Wlev is%d\n', loop_max-loop_min+1); Wlev= loop_max-loop_min+1; ENDWW=1; forloop = loop_max-wlev+1: Loop_max Nii=2^Loop; P1_0= [h_1 Zeros (1, nii-L)]; P2_0= [G_1 Zeros (1, nii-L)]; P1= Zeros (nii/2, NII); P2= Zeros (nii/2, NII);  forIi=1: nii/2P1 (ii,:)=circshift (P1_0', (ii-1) +1-(L-1) +l/2-1)'; P2 (ii,:)=circshift (p2_0', (ii-1) +1-(L-1) +l/2-1)'; End W1=[P1;P2]; MM=2^loop_max-Length (W1); W=[W1,zeros (Length (W1), mm), zeros (Mm,length (W1)), Eye (mm,mm)]; WW=ww*W; Clear P1;clear P2;end%the END!!!End

Verify that the results of the function wavedec with MATLAB are consistent:

%Verify the correctness of the function dwtmtx clear all;close ALL;CLC; N=2^7;%'DB1'Or'Haar','DB2', ... ,'DB10', ... ,'Db45'%'COIF1', ... ,'Coif5'%'sym2', ... ,'SYM8', ... ,'Sym45'%'bior1.1','bior1.3','bior1.5'%'bior2.2','bior2.4','bior2.6','bior2.8'%'bior3.1','bior3.3','bior3.5','bior3.7'%'bior3.9','bior4.4','bior5.5','bior6.8'%'rbio1.1','rbio1.3','rbio1.5'%'rbio2.2','rbio2.4','rbio2.6','rbio2.8'%'rbio3.1','rbio3.3','rbio3.5','rbio3.7'%'rbio3.9','rbio4.4','rbio5.5','rbio6.8'wtype='rbio6.8'; Wlev_max=Wmaxlev (n,wtype);ifWlev_max = =0fprintf ('\nthe parameter N and wtype does not match!\n'); Enddwtmode ('per'); forWlev =1: Wlev_max ww=dwtmtx (N,wtype,wlev); X= Randn (1, N); Y1= (ww*x')'; [Y2,Y2L]=Wavedec (X,wlev,wtype); Y_err= SUM ((y1-y2). * (y1-y2)); fprintf ('Wlev =%d:y_err =%f\n', Wlev,y_err); end

A brief talk on compression perception (14): MATLAB implementation of Fourier matrix and wavelet transform matrix

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.