hellocatfood wrote:... unless I learnt C++ I don't think I could convert it to ImageMagick.
It is written in GMIC's own scripting language. Here is (a version of) that script:
Code: Select all
#@cli polygonize : _warp_amplitude>=0,_smoothness[%]>=0,_min_area[%]>=0,_resolution_x[%]>0,_resolution_y[%]>0
#@cli : Apply polygon effect on selected images.
#@cli : Default values: 'warp_amplitude=300', 'smoothness=2%', 'min_area=0.1%', 'resolution_x=resolution_y=10%'.
#@cli : $ image.jpg +polygonize ,
polygonize : check "${1=300}>=0 && ${2=2%}>=0 && ${3=0.1%}>=0 && ${4=10%}>0 && ${5=$4}>0"
e[^-1] "Polygonize image$? with warp amplitude $1, smoothness $2, minimal area $3 and resolutions ($4,$5)."
v - repeat $! l[$>]
+b $2 gradient_norm. g. a[-2,-1] c channels. 0,2 *. {1/0.1+max(abs(im),abs(iM))}
resx={max(1,round(if(${is_percent\ $4},w*$4,w/$4)-1))}
resy={max(1,round(if(${is_percent\ $5},h*$5,h/$5)-1))}
plane3d 1,1,$resx,$resy *3d. {0,w-1},{0,h-1},1
s3d. rm.. i.. (0;{h-1}) r.. 3,{h},1,1,3 round.. y..
[-4] a[-7--2] y r. 3,{h/3},1,1,-1 z. 0,1 permute. yzcx
repeat $1 +warp[1] .,0,0 +[-2,-1] done
permute. cxyz z. 0,2 y. j[2] .,0,8 rm[-3,-1]
[0],[0] j3d. [1],0,0,0,1,2 rm[1]
if {$3>0}
min_area={0,if(${is_percent\ $3},$3*w*h,$3)}
+area. 0,1 >=. $min_area +.. 1 *.. . distance. 1 *. -1 watershed.. . rm.
fi
blend shapeaverage
endl done v +