What does wpspectrum's output 'Spec' mean? - matlab

Used 'wpspectrum' to do wavelet packet transform, the function have 3 outputs:
[time,freq,Spec].
But I don't know what the Spec mean?
Does it denote energy or wavelet coefficients?

Related

How to produce quadruple density wavelet coefficients?

I refer to this paper, second-page right-column second-paragraph, where it is stated how to produce quadruple density wavelet coefficients:
if we do not down sample the wavelet coefficients we generate
wavelets with double density, where wavelets of level n are centered every 1/2*2^n. To generate the quadruple density dictionary,we compute the scaling coefficients with double density by not down sampling
them. The next step is to calculate double density wavelet coefficients on the two sets of scaling coefficients - even
and odd - separately.
I am confused how to get two sets of scaling coefficients - even and odd. What does it mean by even and odd?
Is that like, split the original image matrix into two matrices with those only even-index (0,0) (0,2)..... and odd-index (0,1),(0,3)...? What is the advantage?
Thanks
Those who has interest for Overcomplete Wavelet Transform, please look at these two links.
http://www.dahlsys.com/cuda/overcomplete_wavelet/index.html
http://eeweb.poly.edu/~onur/source.html
Thanks

Taking fourier transform of a function using symbolic variable

MATLAB failed to compute the fft of this function:
syms t;
x= 1/(1+t^2);
X= fft(x)
And threw this error:
Undefined function 'fft' for input arguments of type 'sym'.
Why didn't it take the Fourier transform of the symbolic variable? I think it should because we may want to obtain the result as a symbolic value.
I also tried to solve the problem with non-symbolic variable.
t= -10:0.01:10;
x= zeros(2001);
x= 1/(1+t.^2);
fft(x)
this time my error is:
Matrix dimensions must agree.
However, they have the same dimensions.
Where is my fault?
Source: http://www.mathworks.com/matlabcentral/newsreader/view_thread/315950
FFT is a method for numerical discrete Fourier Transform (DFT).
Basically, what you're asking doesn't make sense. FFT is designed to work numerically on discrete data (a sequence of numbers).
What you want is the Fourier Transform of your symbolic expression. For that, I believe you want fourier.
The documantation on fft says:
Y = fft(X) computes the discrete Fourier transform (DFT) of X using a fast Fourier transform (FFT) algorithm.
Symbolic functions are continuous, not discrete. Hence, the algorithm fails.
With regards to your second question: use element-wise operators, by adding a dot:
t= -10:0.01:10;
x= zeros(2001);
x= 1./(1+t.^2);
fft(x)
MATLAB complains about matrix dimensions, because you are trying to divide a scalar (i.e. a 1 x 1 matrix) by a vector of length 2001. element-wise division solves that problem.

How does wavedec function in matlab select shifts for a given scale?

In matlab,for wavelet toolbox when we give as input some x, we are specifying the number of stages for decomposition and the mother wavelet,how does the algorithm actually performs the shifting operation for a given scale?

How to perform a smoothing operation on a wavelet decomposition in Matlab?

I have been asked to perform thresholding and smoothing on the wavelet coefficients in the wavelet domain to improve de-noising of an image. I am able to do thresholding by using the Matlab function wthcoef2, but I don't see a function for smoothing that is consistent with Matlab's representation of the wavelet coefficients.
Below is the code I have right now:
F = imread('lena_std.tif'); % Reads the image
F_gray = rgb2gray(F); % Converts from RGB to Gray scale
gausQ = input('Add White Gaussian Noise?: ','s');
if gausQ == 'Y'
F_noisy = imnoise(F_reshape,'gaussian');
F_wavelet = F_noisy;
else
F_wavelet = F_gray;
end
%%
% Asks user for the wavelet decomposition level and the type of wavelet to
% use.
J = input('Choose the wavelet decomposition level: ');
wavelet = input('Choose the wavelet name: ','s');
[C,S] = wavedec2(F_wavelet,J,wavelet); % Multi-level wavelet decomposition
%%% Thresholding done by C = wthcoef2(C,S,N,T,SORH); %%%
My main issue is that the wavelet coefficients are held in a vector, C, that is 1 row by however many columns, and this representation doesn't allow for smoothing operators to be applied (at least not in the way I understand).
I considered trying to reshape the wavelet coefficient vector, but I didn't know how to incorporate the bookkeeping matrix, S, into it correctly.
If anyone has any insight on this issue, please respond accordingly. If I need to add anymore detail to this question, please let me know. Thanks for your help!
I am not sure where you got the idea of lowpass-filtering in the wavelet domain. It is definitely novel but it may not be what you want.
Maybe the more direct two-dimensional fast wavelet transform gives you a better idea of which coefficients go to/come from which image positions:
http://uk.mathworks.com/help/wavelet/ug/two-dimensional-discrete-wavelet-analysis.html

Creating a matrix of Gaussian Wavelets at dyadic scales

I need to create a diagonal matrix containing the Fourier coefficients of the Gaussian wavelet function, but I'm unsure of what to do.
Currently I'm using this function to generate the Haar Wavelet matrix
http://www.mathworks.co.uk/matlabcentral/fileexchange/33625-haar-wavelet-transformation-matrix-implementation/content/ConstructHaarWaveletTransformationMatrix.m
and taking the rows at dyadic scales (2,4,8,16) as the transform:
M= 256
H = ConstructHaarWaveletTransformationMatrix(M);
fi = conj(dftmtx(M))/M;
H = fi*H;
H = H(4,:);
H = diag(H);
etc
How do I repeat this for Gaussian wavelets? Is there a built in Matlab function which will do this for me?
For reference I'm implementing the algorithm in section 4 of this paper:
http://ieeexplore.ieee.org/stamp/stamp.jsp?arnumber=04218361
I maybe would not being answering the question, but i will try to help you advance.
As far as i know, the Matlab Wavelet Toolbox only deal with wavelet operations and coefficients, increase or decrease resolution levels, and similar operations, but do not exposes the internal matrices serving to doing the transformations from signals and coefficients.
Hence i fear the answer to this question is no. Some time ago, i did this for some of the Hart Class wavelet, and i actually build the matrix from the scratch, and then i compared the coefficients obtained with the Built-in Matlab Wavelet Toolbox, hence ensuring your matrices are good enough for your algorithm. In my case, recursive parameter estimation for time varying models.
For the function ConstructHaarWaveletTransformationMatrix it is really simple to create the matrix, because the Hart Class could be really simple expressed as Kronecker products.
The Gaussian Wavelet case as i fear should be done from the scratch too...
THe steps i suggest would be;
Although MATLAB dont include explicitely the matrices, you can use the Matlab built-in functions to recover the Gaussian Wavelets, and thus compose the matrix for your algorithm.
Build every column of the matrix with every Gaussian Wavelet, for every resolution levels you are requiring (the dyadic scales). Use the Matlab Wavelets toolbox for recover the shapes.
After this, compare the coefficients obtained by you, with the coefficients of the toolbox. This way you will correct the order of the Matrix row.
Numerically, being fj the signal projection over Vj (the PHI signals space, scaling functions) at resolution level j, and gj the signal projection over Wj (the PSI signals space, mother functions) at resolution level j, we can write:
f=fj0+sum_{j0}^{j1-1}{gj}
Hence, both fj0 and gj will induce two matrices, lets call them PHIj and PSIj matrices:
f=PHIj0*cj0+sum_{j0}^{j1-1}{PSIj*dj}
The PHIj columns contain the scaled and shifted scaling wavelet signal (one, for j0 only) for the approximation projection (the Vj0 space), and the PSIj columns contain the scaled and shifted mother wavelet signals (several, from j0 to j1-1) for the detail projection (onto the Wj0 to Wj1-1 spaces).
Hence, the Matrix you need is:
PHI=[PHIj0 PSIj0... PSIj1]
Thus you can express you original signal as:
f=PHI*C
where C is a vector of approximation and detail coefficients, for the levels:
C=[cj0' dj0'...dj1']'
The first part, for addressing the PHI build can be achieved by writing:
function PHI=MakePhi(l,str,Jmin,Jmax)
% [PHI]=MakePhi(l,str,Jmin,Jmax)
%
% Build full PHI Wavelet Matrix for obtaining wavelet coefficients
% (extract)
%FILTER
[LO_R,HI_R] = wfilters(str,'r');
lf=length(LO_R);
%PHI BUILD
PHI=[];
laux=l([end-Jmax end-Jmax:end]);
PHI=[PHI MakeWMatrix('a',str,laux)];
for j=Jmax:-1:Jmin
laux=l([end-j end-j:end]);
PHI=[PHI MakeWMatrix('d',str,laux)];
end
the wfilters is a MATLAB built in function, giving the required signal for the approximation and or detail wavelet signals.
The MakeWMatrix function is:
function M=MakeWMatrix(typestr,str,laux)
% M=MakeWMatrix(typestr,str,laux)
%
% Build Wavelet Matrix for obtaining wavelet coefficients
% for a single level vector.
% (extract)
[LO_R,HI_R] = wfilters(str,'r');
if typestr=='a'
F_R=LO_R';
else
F_R=HI_R';
end
la=length(laux);
lin=laux(2); lout=laux(3);
M=MakeCMatrix(F_R,lin,lout);
for i=3:la-1
lin=laux(i); lout=laux(i+1);
Mi=MakeCMatrix(LO_R',lin,lout);
M=Mi*M;
end
and finally the MakeCMatrix is:
function [M]=MakeCMatrix(F_R,lin,lout)
% Convolucion Matrix
% (extract)
lf=length(F_R);
M=[];
for i=1:lin
M(:,i)=[zeros(2*(i-1),1) ;F_R ;zeros(2*(lin-i),1)];
end
M=[zeros(1,lin); M ;zeros(1,lin)];
[ltot,lin]=size(M);
lmin=floor((ltot-lout)/2)+1;
lmax=floor((ltot-lout)/2)+lout;
M=M(lmin:lmax,:);
This last matrix should include some interpolation routine for having better general results in each case.
I expect this solve part of your problem.....
Hyp