annotate arrows/additive_split.m @ 61:eff6bddf82e3 tip

Finally implemented perceptual brightness thing.
author samer
date Sun, 11 Oct 2015 10:20:42 +0100
parents beb8a3f4a345
children
rev   line source
samer@0 1 % additive_split - Arrow to process data with adaptive zero mean
samer@0 2 %
samer@0 3 % additive_split ::
samer@0 4 % arrow( {[N,M]}, {[N,M]}, S1) ~'arrow to process N channel zero mean data',
samer@0 5 % arrow( {[N]}, {[N]}, S2) ~'arrow to process estimated mean',
samer@0 6 % options {} ~'options passed to azeromean'
samer@0 7 % -> arrow( {[N,M]}, {[N,M]}, pair( pair([N],pair(S1,S2)), empty)).
samer@0 8 %
samer@0 9 % This arrow uses the azeromean arrow to adaptively estimate the mean of
samer@0 10 % the N channels of input data, using a gaussian data model. The mean is
samer@0 11 % subtracted out. The two components are then processed independently by
samer@0 12 % the two supplied arrows and added together to create the output.
samer@0 13
samer@0 14 function o=additive_split(a1,a2,varargin)
samer@37 15 opts=options(varargin{:});
samer@0 16
samer@0 17 o = states(azeromean(gaussian,opts))*(a1+a2)*aplus;
samer@0 18 end
samer@0 19
samer@0 20 function o=aplus, o=arrf(@plusfn,2,1); end
samer@0 21 function f=plusfn(sz)
samer@0 22 if all(sz{1}==sz{2}), f=@plus;
samer@0 23 elseif sz{1}(1)==sz{2}(1) && sz{1}(2)>sz{2}(2)
samer@0 24 f=@(a,b)a+repmat(b,1,size(a,2));
samer@0 25 elseif sz{1}(1)==sz{2}(1) && sz{1}(2)<sz{2}(2)
samer@0 26 f=@(a,b)b+repmat(a,1,size(b,2));
samer@0 27 else
samer@0 28 error('additive_split:incompatible sizes');
samer@0 29 end
samer@0 30 end