✍ Testing some code

for stippling images

Here is the code, if you want to have some fun!

clear all
IBW= imread ("stippling_input.jpg");

[n m]=size(IBW);

figure(1)
clf
imshow(IBW)
print -dpng "-S 496,466" "plant.png"
mIBW=mean(mean(IBW))
sIBW=sqrt(mean(mean((mIBW-IBW).^2)))

nplot=15000;
############################################################
k=0;

while (k<=nplot)
  xi=n*rand+1;
  yi=m*rand+1;
  i=floor(xi);
  j=floor(yi);
  rx=rand;
  if (floor((rx+rx^2+rx^3+rx^4+rx^10)*255/5)>=IBW(i,j))
    k=k+1;
    x(k)=xi/n;
    y(k)=yi/n;

  end
end

figure(2)
clf
plot(y(1:nplot),1-x(1:nplot),'k.',"markersize", 2)
axis([0 1 0 m/n])
axis off
title("Geometric")
print -dpng "-S 496,466" "plant_r.png"


############################################################
clear x
clear y

k=0;
while (k<=nplot)
  xi=n*rand+1;
  yi=m*rand+1;
  i=floor(xi);
  j=floor(yi);
#  randx=abs(random("normal", mIBW, sIBW));

  if (floor(brand*255)>IBW(i,j))
    k=k+1;
    x(k)=xi/n;
    y(k)=yi/n;
  end
end

figure(3)
clf
plot(y(1:nplot),1-x(1:nplot),'k.',"markersize", 2)
axis([0 1 0 m/n])
axis off
title("Blue Noise")
print -dpng "-S 496,466" "plant_blue.png"
############################################################

############################################################
clear x
clear y

k=0;
while (k<=nplot)
  xi=n*rand+1;
  yi=m*rand+1;
  i=floor(xi);
  j=floor(yi);

  if (floor(rand*255)>=IBW(i,j))
    k=k+1;
    x(k)=xi/n;
    y(k)=yi/n;
  end
end
k

figure(4)
clf
plot(y(1:nplot),1-x(1:nplot),'k.',"markersize", 2)
axis([0 1 0 m/n])
axis off
title("Uniform")
print -dpng "-S 496,466" "plant_rand.png"


############################################################

Palavras chave/keywords: image, octave, stippling image

Criado/Created: 20-02-2015 [14:11]

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


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.