I am trying to create a dynamic random dots stereogram by updating the position of the dots, so that I can get an inward motion of the dots (optic flow). I first created a disk filled with dots whose position is randomised:
se = strel('disk',4);
x = linspace(-1,1,768); %generates 768 points in a vector with a [-1:1] interval
[X,Y] = meshgrid(x,x); %generates a rectangular grid in replicating the x vector.
[T,R] = cart2pol(X,Y);
threshold = 1 - (dot_nb / 768^2); %dot_nb=5;
Rd = double(rand(768,768)>threshold);
Rd(R>0.95 | R<0.06)=0; %remove some of the dots in order to get a circle and no dots in the middle of it
I am now trying to update the location of the dots at a specific refresh rate (20Hz) but I am having troubles with it. I thought the following lines of code (which are in a bigger loop controlling the frame rate) could work but obviously something is missing and I do not know how else I could do it:
update = 0.1;
for i = 1:size(R,1) %R is the matrix with the radius values of the dots
for j = 1:size(R,2)
if R(i,j)<0.95 && R(i,j)>0.06
R(i,j) = R(i,j)-update;
else
R(i,j)=0;
end
end
end
Has anyone any idea how I could do to get what I'm looking for? Thank you in advance!
Aucun commentaire:
Enregistrer un commentaire