Advertisement
Guest User

Spherize in G'MIC

a guest
Oct 3rd, 2017
519
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.29 KB | None | 0 0
  1. #@cli spherize : _radius[%]>=0,_strength,_smoothness[%]>=0,_center_x[%],_center_y[%],_interpolation
  2. #@cli : Apply spherize effect on selected images.
  3. #@cli : Default values: 'radius=50%', 'strength=1', 'smoothness=0', 'center_x=center_y=50%' and 'interpolation=1'.
  4. #@cli : $ image.jpg -grid 5%,5%,0,0,0.6,255 --spherize ,
  5. spherize : -check "${1=50%}>=0 && ${3=0}>=0 && isint(${6=1}) && $6>=0 && $6<=2 && isint(${7=1}) && $7>=0 && $7<=3" -skip "${2=1},${4=50%},${5=50%}"
  6.   -e[^-1] "Apply spherize effect on image$?, with radius $1, strength $2, smoothness $3, center ($4,$5) and "${"-arg 1+$6,nearest-neighbor,linear,cubic"}" interpolation."
  7.   -if {!$1||!$2} -return -endif
  8.   -v - -repeat $! -l[$>]
  9.     rmax={${"-is_percent $1"}?0.5*sqrt((w-1)^2+(h-1)^2)*$1:$1}
  10.     centerx={${"-is_percent $4"}?(w-1)*$4:$4}
  11.     centery={${"-is_percent $5"}?(h-1)*$5:$5}
  12.     strength={$2>0?$2:1-exp($2/5)}
  13.     100%,100%,1,2,"
  14.      init(
  15.        center = [ "$centerx","$centery" ];
  16.        wh1 = [ w,h ] - 1;
  17.        m2wh1 = 0.5*max(wh1);
  18.        rmax = "$rmax"/m2wh1;
  19.        const f = 1/"$strength";
  20.      );
  21.      xy = ([x,y] - center)/m2wh1;
  22.      r = norm2(xy);
  23.      z = r<rmax?sign($2)*sqrt(rmax^2 - r^2):0;
  24.      xy = center + f*xy/(f + z)*m2wh1"
  25.     -b. $3
  26.     -warp.. .,0,$6,1 -rm.
  27.   -endl -done -v +
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement