Created
February 8, 2017 13:06
-
-
Save ekatrukha/a4e16360b59a0ba4e2c828efc63b396b to your computer and use it in GitHub Desktop.
1D spatio-temporal correlation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clear all | |
%% READ IMAGE FROM FILE | |
I=imread('kymo.bmp'); | |
%maximum delay time (in frames) | |
nMaxTime = 60; | |
imheight=size(I,1); %time | |
imwidth=size(I,2); %space | |
I=double(I); | |
nTotLineXC=NaN(2*imwidth+1,nMaxTime); | |
%deltat | |
for dt=0:nMaxTime | |
%include negative | |
%for dx=0:(imwidth-1) | |
for dx=(1-imwidth):(imwidth-1) | |
dMeanxx=0; | |
dMeanxy=0; | |
dCount=0; | |
for t=1:(imheight-dt) | |
%let's define min and max | |
if(dx>=0) | |
imin=1; | |
imax=(imwidth-dx); | |
else | |
imin=1-dx; | |
imax=imwidth; | |
end | |
%for(i=1:(imwidth-dx)) | |
for(i=imin:imax) | |
dMeanxy = dMeanxy+I(t,i)*I(t+dt,i+dx); | |
dMeanxx=dMeanxx + I(t,i); | |
dCount=dCount+1; | |
end | |
end | |
dMeanxy=dMeanxy/dCount; | |
dMeanxx=dMeanxx/dCount; | |
nTotLineXC(dx+imwidth,dt+1)=(dMeanxy/(dMeanxx*dMeanxx))-1; | |
end | |
end | |
figure | |
%limit space correlation length | |
xrange=(round(imwidth*0.5):round(imwidth*1.5)); | |
%plot | |
imagesc(nTotLineXC(xrange,:)); | |
axis equal |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment