[62fbef]: wavelets / pack2cell.m  Maximize  Restore  History

Download this file

69 lines (53 with data), 1.5 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
function ccell = pack2cell(cvec,Lc,varargin)
%PACK2CELL Changes wavelet coefficients storing format
% Usage:
% ccell = pack2cell(cvec,Lc);
% ccell = pack2cell(cvec,Lc,bands);
%
% Input parameters:
% cvec : Coefficients in packed format.
% Lc : J+1 element vector containing coefficients lengths.
% bands : Number of wavelet filters
%
% Output parameters:
% ccell : Coefficients stored in J+1 cell-array.
%
% *cvec* is collumn vector or matrix with *W* collumns for multi-channel inputs containing
% coefficients in the packed format. Coefficients are stored as folows:
% cvec(1:lengths(1),w) - approximation coefficients at level *J* of the channel *w*,
% cvec(1+sum(lengths(1:j-1)):sum(lengths(1:j),w) for *j=2,...,J+1* - detail coefficients at
% level *J-2+j*.
%
if(isempty(varargin))
bands = 1;
else
bands = varargin{1}-1;
end
% check if (length(Lc)-1)/bands is integer
JJ = (length(Lc)-1)/bands + 1;
[cLen, W] = size(cvec);
% ALLOCATING OUTPUT
ccell = cell(JJ,bands);
ccell{1} = zeros(Lc(1),W);
jjIdx = 2;
for jj=2:JJ
for bb=1:bands
ccell{jj,bb} = zeros(Lc(jjIdx),W);
jjIdx = jjIdx +1;
end
end
% DO THE COPY
for w=1:W
ccell{1}(:,w) = cvec(1:Lc(1),w);
end
for w=1:W
lenSumIdx = 1;
lenSum = Lc(lenSumIdx);
for jj=2:JJ
for bb=1:bands
ccell{jj,bb}(:,w) = cvec(1+lenSum:Lc(lenSumIdx+1)+lenSum,w);
lenSum = lenSum+Lc(lenSumIdx+1);
lenSumIdx=lenSumIdx+1;
end
end
end

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks