G’MIC Doodling in the absence of discuss.pixls.us. In particular, an emulator for New York Abstract Expressionism ‘action painting.’ You can be the next Pollack! My contribution to the Mysteries of Domain Warping.
warpfun.gmic
#@cli warpfun : stircount>0,noisefunc="spikes",arg0>0,arg1>0,arg2>0
#@cli : Using selected images as bases, emulate New
#@cli : York Abstract Expressionism School's 'action
#@cli : painting', as exercised by Jackson Pollack et
#@cli : al. in the 1950's-60's. stircount: number of
#@cli : times to swirl around the mathematical space
#@cli : where the 'action painting' is
#@cli : embedded. Style: selects one from a number of
#@cli : warping patterns: checkbrd(0), perlin(1),
#@cli : plasma(2), (3)ripples and (4)spikes. Arg0 and
#@cli : arg1: warping dependent arguments. Arg2:
#@cli : Attenuation. Scales stirring strength from 0
#@cli : (zero - no warping takes place) to 1 (one -
#@cli : maximum warping). Pressing <ESC> whilst the
#@cli : monitor window is active to stop stirring and
#@cli : finish up with the image as is.
#@cli : $ -input myimage.jpg warpfun. 4,0.25
warpfun : -check "isnum(${3=0.5}) && $3>0 &&
isnum(${4=0}) && $4>=0 &&
isnum(${5=0}) && $5>=0"
-skip "${1=32},${2=4}"
scnt,nfunc,a0,a1,attn=${1-5}
# Pick one of the noise makers cited in $pats,
# either by numeric id or name. Put the name in
# '$pat', if known, otherwise default $pat to
# 'spikes'.
pats=${-_noise_pats}
N:=narg($pats)
-local[] {
# Specify noise maker by number? Use that,
# modulo the noise maker count, as an index
# into the set of available noise
# makers. Otherwise take specification as a
# string and check if it matches the name of
# one of the available noise makers. Default
# to 'spikes' noise maker in the absence of a
# match.
-if isint($2)
pat=${"arg0 ($2%"$N"),"$pats}
-else
pat,flag=$2,0
-repeat $N {
C=${"arg0 "$>","$pats}
-if ['$C']==['$pat']
flag=1
-break
-fi
}
-if !$flag
pat=spikes
-fi
-fi
}
-foreach {
nm={n}
-name. current
# One stir entails a number of discrete warps (lvls)
# derived from the largest of image width or depth:
# the base-2 log of this measure, rounded to the
# nearest higher whole number, sets lvl and the
# dimensions of the 2D "stirring space" a square
# power-of-two dimensioned image. We embed the
# currently selected image in this space,mirroring
# content as a means to manage a mirror-based border
# policy.
lvls={round(log(max(w,h))/log(2),1,1)}
ow,oh,dx,dy={w},{h},{2^$lvls-w},{2^$lvls-h}
-expand_x[current] {$dx/2},3
-expand_y[current] {$dy/2},3
# Displacement fields, one each for a lvl-count
# of scale-based warping images. A Haar analysis
# of distance-to-salt-and-pepper noise spikes defines
# the warping images. See Haar tutorial at gmic.eu.
# Generate a noise pattern image from the selected
# noise maker. Decompose that image into scale-specific
# displacement vector fields, the number dependent on
# the base-two logarithm of the current image's largest
# dimension.
100%,100%,1,1
_$pat. $a0,$a1
-normalize. 0,{255*$attn}
-haar. $lvls
-repeat $lvls
-local[-1]
-split[-1] yx,2
-name ctr,ne,sw,diff
-move[ctr] $!
-done
-done
# Make warping images based on Haar sum-of-differences
# and differences of sums. TODO: Differences of
# differences (diff) could be put to some use, no?
-remove[diff,ctr]
-local[ne,sw]
-repeat {($!/2)}
-local[{2*$<},{2*$<+1}]
-append c
-done
-done
-done
-resize[^current] {w#$current},{h#$current},{d#$current},2,5
-foreach[^current] {
lim={im#0}
liM={iM#0}
-orientation.
-normalize {$lim},{$liM}
}
-mul[^current] {1.0/($scnt)}
# Stir image through a gamut of scaled displacement fields.
flag=0
-do
cs={$>+1}
-repeat {$!-1}
cw={$>+1}
-warp[current] [{$<+1}],1,2,3
+crop[current] {$dx/2},{$dy/2},{$ow+($dx/2)-1},{$oh+($dy/2)-1}
-name. preview
-text_outline[preview] "Warp\ "$cw"\ of\ "{$!-2}";\ Stir\ number:\ "$cs"\ of\ "$scnt"\ Attenuation:\ "$attn,3%,85%,3%,1,1,255,240,200
-window[preview]
-wait 250
-remove[preview]
-if {*,ESC}
flag=1
-break
-fi
-done
-while $><$scnt-1" && "$flag==0
-keep[current]
-crop[current] {$dx/2},{$dy/2},{$ow+($dx/2)-1},{$oh+($dy/2)-1}
-normalize[current] 0,255
-name[current] $nm
}
# Noise functions: generate sets of displacement fields
# from images painted by these functions. Each should return
# a one channel image with channel values ranging from 0-255.
_noise_pats :
-status checkbrd,perlin,plasma,ripples,spikes
_checkbrd : -check "isnum(${1=16}) && isnum(${2=8})"
foreach {
-fill. xor(x,y)%$1<$2?1:0
-distance. 1,2
}
_perlin : -check "isnum(${1=16}) && isnum(${2=16})"
foreach {
-noise_perlin. {$1},{$2}
}
_plasma : -check "isnum(${1=16}) && isnum(${2=16})"
foreach {
-plasma. {0.01*$1},{0.01*$2},{($1*$2)%8}
-abs.
}
_ripples : -check "isnum(${1=16})" -skip ${2=16}
foreach {
-input {$1},1,1,3,[u(w#-1),u(h#-1),u>=0.5?-1:1]
-rbf. {w#-2},{h#-2}
-abs.
-mod {1/$2}
-keep.
}
_spikes : -check "isnum(${1=0.5}) && isnum(${2=0})"
-noise. {0.0001*$1},2
-abs.
-normalize. 0,1
-if $2>0
100%,100%,1,1
-plasma. 0.5,0.5,{$2%8}
-normalize. 0,{1+$2}
-distance.. 1,[-1],0
-remove.
-else
-distance. 1,2
-fi
A Haar wavelet decomposition of a noise field furnishes the Domain Warping mystique.
stircount: number of times to swirl around the mathematical space where the ‘action painting’ is embedded. Style: selects one from a number of warping patterns: checkbrd (0), perlin (1), plasma (2), ripples (3) and spikes (4); choose by name or number. Arg0 and arg1 are warping dependent arguments. See examples for guidance. Arg2: Attenuates stirring strength. Unity is full strength; such decreases on an approach to Zero. See examples for guidance. As it proceeds, it throws up an interactive window showing progress; hit <ESC> in the interactive window if an intermediary result strikes your fancy. That stops further warpage.
gmic run '-m warpfun.gmic sample portrait4,512 warpfun. 4,4,13,5,0.02 n. 0,255'

gmic run '-m warpfun.gmic 512,512,1,1,255*x/(w-1) map jet warpfun. 3,spikes,135,5,0.05 n. 0,255'

gmic run '-m warpfun.gmic sp cat,512 warpfun. 3,ripples,50,6,0.05'

gmic run '-m warpfun.gmic sp flower,512 warpfun. 6,plasma,1,9,0.05 n. 0,255'

gmic run '-m warpfun.gmic 512,512,1,1,255*y/(h-1) map rainbow warpfun. 2,checkbrd,71,3,0.2 n. 0,255'

gmic run '-m warpfun.gmic 512,512,1,1,255*y/(h-1) map hocuspocus warpfun. 5,perlin,200,20,0.02 n. 0,255'

Have fun!