✍ Random Walk on a image

...

clear all
IBW= mean(imread ("horse.jpg"),3);
[n m]=size(IBW);

nplot=50000;

k=1;
l=1;
x(1)=l/2;
y(1)=l/2;
T=10;

while(k<nplot)
  rx=rand;
  ry=rand;
  i=floor(n*x(k)/l)+1;
  j=floor(m*y(k)/l)+1;
  A=(IBW(i,j)/(T*255));
  x(k+1)=x(k)+rx*A*(-1)^floor(10*rand+1);
  y(k+1)=y(k)+ry*A*(-1)^floor(10*rand+1);
  if (x(k+1)>l)
    x(k+1)=l-rx*A;
  end
  if(x(k+1)<0)
    x(k+1)=rx*A;
  end
  if (y(k+1)>l)
    y(k+1)=l-ry*A;
  end
  if(y(k+1)<0)
    y(k+1)=ry*A;
  end
  k=k+1;
end

plot(y,1-x,'k-')
axis off
print -dpng "-S 680,436" "random_horse.png"
Palavras chave/keywords: random walk, image, jpg, Octave

Criado/Created: 20-02-2015 [23:02]

Última actualização/Last updated: 23-01-2017 [09:20]


GNU/Emacs

1999-2017 (ç) Tiago Charters de Azevedo

São permitidas cópias textuais parciais/integrais em qualquer meio com/sem alterações desde que se mantenha este aviso.

Verbatim copying and redistribution of this entire page are permitted provided this notice is preserved.