Averaging method with sliding window

1 view (last 30 days)
kaiba Wong
kaiba Wong on 1 Apr 2013
m =100; %vertical window size in samples; n =50; %shift
B=zeros(nz,nx+n,ny); B(:,1:nx,:)=Bnew;
M=zeros(nz,nx+n,ny); M(:,1:nx,:)=Mnew;
B1=reshape(B,[nz ny*(nx+50)]); M1=reshape(M,[nz ny*(nx+50)]);
fun=@(x) mean(x(:));
tic;
scaleB=nlfilter(B1(:,:,:),[m n],fun);
scaleM=nlfilter(M1(:,:,:),[m n],fun);
toc;
I am trying to find a scaling factor btw Bnew and Mnew...using a sliding window in nlfilter however, the averaging is too detail. Is there a way to output an averaging scalar across the window for a certain interval. I need the scaling factor to vary slowly.
Thank you !

Answers (1)

Image Analyst
Image Analyst on 1 Apr 2013
What does "btw Bnew and Mnew" mean? What is "btw" - between? Between what? Or "by the way"?
Anyway, I don't see any scaling factor sent into fun, so I'm not sure how you would want to use it if you had one. You're not even doing a non-linear filter so there's no reason to use a super flexible function like nlfilter(). Why not just use convn()? That will blur a 3D array very efficiently - convn() is highly optimized.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!