Advertisement
Guest User

Code of G'MIC -quiver command

a guest
Sep 29th, 2017
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.48 KB | None | 0 0
  1. #@cli quiver : [function_image],_sampling[%]>0,_factor>=0,_is_arrow={ 0 | 1 },_opacity,_color1,...
  2. #@cli : Draw specified 2d vector/orientation field on selected images.
  3. #@cli : Default values: 'sampling=5%', 'factor=1', 'is_arrow=1', 'opacity=1', 'pattern=(undefined)'
  4. #@cli : and 'color1=0'.
  5. #@cli : $ 100,100,1,2,'if(c==0,x-w/2,y-h/2)' 500,500,1,3,255 -quiver[-1] [-2],10
  6. #@cli : $ image.jpg --resize2dy 600 -luminance[0] -gradient[0] -mul[1] -1 -reverse[0,1] -append[0,1] c -blur[0] 8 -orientation[0] -quiver[1] [0],20,1,1,0.8,255
  7. quiver : -check ${"-is_image_arg $1"}" && ${2=5%}>0 && ${3=1}>=0 && isbool(${4=1})" -skip "${5=1},${6=0}"
  8.   -e[^-1] "Draw 2d vector field $1 on image$?, with sampling $2, factor $3, arrows "${"-arg 1+$4,disabled,enabled"}", opacity $5 and color (${6--1})."
  9.   -v - -pass$1 -repeat {$!-1} -l[$>,-1]
  10.     -eval ${-math_lib}"
  11.      s_sampling = ['$2'];
  12.      sampling = s_sampling[size(s_sampling) - 1 ]==_'%'?min(w#0,h#0)*$2:$2;
  13.      vmax = max(abs(im),abs(iM));
  14.      vmax = vmax?vmax:1;
  15.      fact = $3*sampling/vmax;
  16.      for (y = sampling/2, y<h#0, y+=sampling,
  17.        for (x = sampling/2, x<w#0, x+=sampling,
  18.          X = round(x*w/w#0); Y = round(y*h/h#0);
  19.          u = i(X,Y,0,0)*fact; v = i(X,Y,0,1)*fact;
  20.          if ($4,
  21.            draw_arrow(#0,[x,y],[x + u,y + v],45,sampling/4,$5,[${6--1}]),
  22.            draw_line(#0,[x - 0.5*u,y - 0.5*v],[x + 0.5*u,y + 0.5*v],$5,[${6--1}]);
  23.          );
  24.        );
  25.      );
  26.    "
  27.   -endl -done -rm. -v +
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement