From: Tirta Dhany on 7 Jan 2010 02:57 Hi, Guys I want to apply filter2 to cell array to get mean value. Each cell have format like this: [128x128x6 double] [64x64x6 double] [32x32x6 double] I'm using code that <a href="http://www.mathworks.com/matlabcentral/newsreader/author/11763">us</a> at my question in http://www.mathworks.com/matlabcentral/newsreader/view_thread/269422 to puts each page from a multipage CELL into its own CELL {m x n x p} -> {m x n} : page 1 {m x n} : page 2 ... {m x n} : page P Apply to each page, and average them. So, I modified the code in rt ns=size(Yh_abs,1); s=cellfun(@size,Yh_abs,'uni',false); fh=@(m,n) mat2cell(cat(3,m{n}),s{n}(1),s{n}(2),ones(1,s{n}(3))); r=cell(ns,1); for i=1:ns rt=cellfun(@(x) filter2(window, x, 'valid'), fh(Yh_abs,i),'UniformOutput',false); end r=cat(3,r{:}); mu1 = mean2(r); this code return NaN , how to solve this ? Thanks
From: Tirta Dhany on 7 Jan 2010 04:30 That code is not complete. window = fspecial('gaussian', 16, 1.5); ns=size(Yh_abs,1); s=cellfun(@size,Yh_abs,'uni',false); fh=@(m,n) mat2cell(cat(3,m{n}),s{n}(1),s{n}(2),ones(1,s{n}(3))); r=cell(ns,1); for i=1:ns rt=cellfun(@(x) filter2(window, x, 'valid'),fh(Yh_abs,i),'UniformOutput',false); r{i}=mean(cat(3,rt{:})); end %r=cat(3,r{:}); %filter_value = mean2(r); filter_value = mean2(cellfun(@mean2, r)); is rt code is right? I modify r{i}=mean(cat(3,rt{:}),3); to r{i}=mean(cat(3,rt{:})); in r=cat(3,r{:}); i got error msg CAT arguments dimensions are not consistent. After modify r{i} and exclude r=cat(3,r{:});, I get the value. Is apply filter2 to matrix is same as we apply average?
|
Pages: 1 Prev: Multiple Markers for One Legend Entry Next: query regarding odexx |