comparison util/sparco utils/completeOps.m @ 77:62f20b91d870

add routines from sparco problems privite folder to {root}\util some changes to ksvd vs rlsdla image denoising example
author Ivan <ivan.damnjanovic@eecs.qmul.ac.uk>
date Fri, 25 Mar 2011 14:01:50 +0000
parents
children
comparison
equal deleted inserted replaced
76:d052ec5b742f 77:62f20b91d870
1 function data = completeOps(data)
2
3 % Copyright 2008, Ewout van den Berg and Michael P. Friedlander
4 % http://www.cs.ubc.ca/labs/scl/sparco
5 % $Id: completeOps.m 1040 2008-06-26 20:29:02Z ewout78 $
6
7 operators = {};
8 flagM = 0; if isfield(data,'M'), flagM = 1; end;
9 flagB = 0; if isfield(data,'B'), flagB = 1; end;
10
11 if (~flagM) && (~flagB)
12 error('At least one of the operators M or B has be to given.');
13 end
14
15 % Define measurement matrix if needed
16 if ~flagM
17 info = data.B([],0);
18 data.M = opDirac(info{1});
19 else
20 operators{end+1} = data.M;
21 end
22
23 % Define sparsity basis if needed
24 if ~flagB
25 info = data.M([],0);
26 data.B = opDirac(info{2});
27 else
28 operators{end+1} = data.B;
29 end
30
31 % Define operator A if needed
32 if ~isfield(data,'A')
33 if (length(operators) > 1)
34 data.A = opFoG(operators{:});
35 else
36 data.A = operators{1};
37 end
38 end
39
40 % Define empty solution if needed
41 if ~isfield(data,'x0')
42 data.x0 = [];
43 end
44
45 % Define the operator size and string
46 opInfo = data.A([],0);
47 data.sizeA = [opInfo{1},opInfo{2}];
48 opInfo = data.B([],0);
49 data.sizeB = [opInfo{1},opInfo{2}];
50 opInfo = data.M([],0);
51 data.sizeM = [opInfo{1},opInfo{2}];
52 data.op.strA = opToString(data.A);
53 data.op.strB = opToString(data.B);
54 data.op.strM = opToString(data.M);
55
56 % Get the size of the desired signal
57 if ~isfield(data,'signalSize')
58 if ~isfield(data,'signal')
59 error(['At least one of the fields signal ', ...
60 'or signalSize must be given.']);
61 end
62 data.signalSize = size(data.signal);
63 end
64
65 % Reconstruct signal from sparse coefficients
66 if ~isfield(data,'reconstruct')
67 data.reconstruct = @(x) reshape(data.B(x,1),data.signalSize);
68 end
69
70 % Reorder the fields (sort alphabetically)
71 m = fieldnames(data);
72 m = sort(m);
73 dataReorder = struct();
74 for i=1:length(m)
75 eval(sprintf('dataReorder.%s = data.%s;',m{i},m{i}));
76 end
77
78 data = dataReorder;