How can I make a sliding window that's can slide over the signal (pic) ?

5 views (last 30 days)
I want to make a window with two equal halves that's at the middle it's located (each time) at sample number n for example, then the right half of this window is subtracted from the left half each step/sample number. like the picture shows:

Answers (2)

K E
K E on 5 Mar 2012
I would output your Simulink time series to the Matlab workspace (for example using the To Workspace block) then make a script to perform this calculation. You do not say how you obtain 1 value from the block operation, so I assume point n is the mean difference of the adjacent left and right block. Here is an example approach,
% simTime is output time stamp, simData is output value at time stamp
filteredData = NaN.*simData ;
blockLength = 10 ; % Number of points in left and right block
for iTime = (blockLength + 1):(length(simTime) - blockLength)
iLeftBlock = iTime - blockLength ; % index to left block
iRightBlock = iTime + blockLength ; % index to right block
filteredData(iTime) = mean(simData(iRightBlock) - simData(iLeftBlock)) ;
end

Image Analyst
Image Analyst on 5 Mar 2012
You can call conv() for signals or conv2() or imfilter() for pictures. Usually the center element is replaced by the value of the filter applied to the signal so that's why you usually have odd sized windows, like 3 or 5 or 7. So, what is "half" in that case? You could ignore the middle element if you want like this
kernel = [-1 -1 0 1 1]/2;
filteredSignal = conv(signal, kernel);
Otherwise for even numbered window widths there will be a half-element shift in the output.
  1 Comment
ANIMA V A
ANIMA V A on 4 Dec 2015
how can i slide the window that i have created
if true
for i=2
for j=2
for k=2
Kernel=Out_img(k-1:k+1,j-1:j+1,i-1:i+1);
MinValue=min(Kernel(:));
MaxValue=max(Kernel(:));
NormValue=MaxValue-MinValue;
fv1=Kernel(i,j,k)/NormValue;
fv2=mean2(Kernel);
fv3=std2(Kernel);
fv4=skewness(Kernel(:));
fv5=kurtosis(Kernel(:));
[fv6 fv7 fv8]=gradient(Kernel);
fv6=fv6(2,2,2);
fv7=fv7(2,2,2);
fv8=fv8(2,2,2);
[Dxx1,Dxy1,Dyy1]=Hessian2D(Kernel,1);
M11=[Dxy1];
[Evectors1,Eval1]=eig(M11(:,:,3));
Evalues1=diag(Eval1);
fv9=Evalues1(1);
fv10=Evalues1(2);
fv11=Evalues1(3);
[Dxx2,Dxy2,Dyy2]=Hessian2D(Kernel,3);
M22=[Dxy2];
[Evectors2,Eval2]=eig(M22(:,:,3));
Evalues2=diag(Eval2);
fv12=Evalues2(1);
fv13=Evalues2(2);
fv14=Evalues2(3);
[Dxx3,Dxy3,Dyy3]=Hessian2D(Kernel,6);
M33=[Dxy3];
[Evectors3,Eval3]=eig(M33(:,:,3));
Evalues3=diag(Eval3);
fv15=Evalues3(1);
fv16=Evalues3(2);
fv17=Evalues3(3);
[Dxx4,Dxy4,Dyy4]=Hessian2D(Kernel,9);
M44=[Dxy4];
[Evectors4,Eval4]=eig(M44(:,:,3));
Evalues4=diag(Eval4);
fv18=Evalues4(1);
fv19=Evalues4(2);
fv20=Evalues4(3);
[Dxx5,Dxy5,Dyy5]=Hessian2D(Kernel,14);
M55=[Dxy5];
[Evectors5,Eval5]=eig(M55(:,:,3));
Evalues5=diag(Eval5);
fv21=Evalues5(1);
fv22=Evalues5(2);
fv23=Evalues5(3);
end
end
end
end
how can i slide this all over the image, anyone help me please.....
Thanks in advance,
Anima

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!