[e6709d]: demos / wilgrouplasso.m  Maximize  Restore  History

Download this file

81 lines (72 with data), 2.0 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
function [xo,N]=wilgrouplasso(xi,lambda,varargin);
%WILGROUPLASSO group lasso estimate (hard/soft) in time-frequency domain
% Usage: xo=wilgrouplasso(x,lambda,...);
% [xo,N]=wilgrouplasso(x,lambda,...));
%
% `wilgrouplasso(x,lambda,'time','hard')` will perform group thresholding on
% *x*, i.e. all time-frequency groups whose norm is less than *lambda* will be
% set to zero.
%
% The function takes the following optional parameters at the end of
% the line of input arguments:
%
% 'freq' Group in frequency (search for tonal components). This is the
% default.
%
% 'time' Group in time (search for transient components).
%
% 'hard' Use hard thresholding. This is the default.
%
% 'soft' Use soft thresholding.
%
% `[xo,N]=wilgrouplasso(x,lambda,...)` additionally returns a number *N*
% specifying how many numbers where kept.
%
% The function may meaningfully be applied to output from WMDCT or from
% `wil2rect(dwilt(...))` using an ortonormal transform.
%
% See also: gablasso
%
% Demos: demo_audioshrink
%
% References: Kowalski08sparsity kowalski2009mixed
% AUTHOR : Bruno Torresani.
% REFERENCE: OK
if nargin<2
error('%s: Too few input parameters.',upper(mfilename));
end;
% Define initial value for flags and key/value pairs.
definput.flags.group={'freq','time'};
definput.flags.thresh={'hard','soft'};
[flags,kv]=ltfatarghelper({},definput,varargin);
M = size(xi,1);
N = size(xi,2);
xo = zeros(size(xi));
if flags.do_time
for t=1:N,
threshold = norm(xi(:,t));
mask = (1-lambda/threshold);
if flags.do_soft
mask = mask * (mask>0);
else
mask = (mask>0);
end
xo(:,t) = xi(:,t) * mask;
end
else
for f=1:M,
threshold = norm(xi(f,:));
mask = (1-lambda/threshold);
mask = mask * (mask>0);
if flags.do_soft
mask = mask * (mask>0);
else
mask = (mask>0);
end
xo(f,:) = xi(f,:) * mask;
end
end;
if nargout==2
signif_map = (abs(xo)>0);
N = sum(signif_map(:));
end

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

Sign up for the SourceForge newsletter:





No, thanks