PTdecode/CImg-1.3.0/examples/gmic_def.raw

Mon, 03 Aug 2009 23:39:53 +0100

author
Philip Pemberton <philpem@philpem.me.uk>
date
Mon, 03 Aug 2009 23:39:53 +0100
changeset 10
604c205d9163
parent 5
1204ebf9340d
permissions
-rwxr-xr-x

add basic test routine for Ptouch library

philpem@5 1 #
philpem@5 2 # File : gmic_def.raw
philpem@5 3 # ( G'MIC default macro file )
philpem@5 4 #
philpem@5 5 # Description : Define additional commands for G'MIC (GREYC's Magic Image Converter).
philpem@5 6 # ( http://gmic.sourceforge.net )
philpem@5 7 # This file is also a part of the CImg Library project.
philpem@5 8 # ( http://cimg.sourceforge.net )
philpem@5 9 #
philpem@5 10 # Usage : gmic [-m gmic_def.raw] (...)
philpem@5 11 #
philpem@5 12 # Note : This file is here for illustration purposes, since commands defined in
philpem@5 13 # the default macro file are already present by default in G'MIC.
philpem@5 14 # Then, explicit inclusion of this file (using the '-m' option) if
philpem@5 15 # useless.
philpem@5 16 #
philpem@5 17 # Copyright : David Tschumperle
philpem@5 18 # ( http://www.greyc.ensicaen.fr/~dtschump/ )
philpem@5 19 #
philpem@5 20 # License : CeCILL v2.0
philpem@5 21 # ( http://www.cecill.info/licences/Licence_CeCILL_V2-en.html )
philpem@5 22 #
philpem@5 23 # This software is governed by the CeCILL license under French law and
philpem@5 24 # abiding by the rules of distribution of free software. You can use,
philpem@5 25 # modify and/ or redistribute the software under the terms of the CeCILL
philpem@5 26 # license as circulated by CEA, CNRS and INRIA at the following URL
philpem@5 27 # "http://www.cecill.info".
philpem@5 28 #
philpem@5 29 # As a counterpart to the access to the source code and rights to copy,
philpem@5 30 # modify and redistribute granted by the license, users are provided only
philpem@5 31 # with a limited warranty and the software's author, the holder of the
philpem@5 32 # economic rights, and the successive licensors have only limited
philpem@5 33 # liability.
philpem@5 34 #
philpem@5 35 # In this respect, the user's attention is drawn to the risks associated
philpem@5 36 # with loading, using, modifying and/or developing or reproducing the
philpem@5 37 # software by the user in light of its specific status of free software,
philpem@5 38 # that may mean that it is complicated to manipulate, and that also
philpem@5 39 # therefore means that it is reserved for developers and experienced
philpem@5 40 # professionals having in-depth computer knowledge. Users are therefore
philpem@5 41 # encouraged to load and test the software's suitability as regards their
philpem@5 42 # requirements in conditions enabling the security of their systems and/or
philpem@5 43 # data to be ensured and, more generally, to use and operate it in the
philpem@5 44 # same conditions as regards security.
philpem@5 45 #
philpem@5 46 # The fact that you are presently reading this means that you have had
philpem@5 47 # knowledge of the CeCILL license and that you accept its terms.
philpem@5 48 #
philpem@5 49
philpem@5 50 #----------------------------------------
philpem@5 51 #
philpem@5 52 # Get and display image characteristics
philpem@5 53 #
philpem@5 54 #----------------------------------------
philpem@5 55
philpem@5 56 # Compute image gradient norm.
philpem@5 57 #-----------------------------
philpem@5 58 #@gmic gradient_norm : (no args) : Compute gradient norm of the last image.
philpem@5 59 gradient_norm :
philpem@5 60 -e "Compute gradient norm of the last image."
philpem@5 61 -v- -t float -gradient[-1] xyz -a[-3--1] v -norm[-1] -sqrt[-1] -v+
philpem@5 62
philpem@5 63 # Compute image gradient orientation in 'N'-D.
philpem@5 64 #---------------------------------------------
philpem@5 65 #@gmic gradient_orientation : N=3 : Compute N-D gradient orientation of the last image.
philpem@5 66 _gradient_orientation3 :
philpem@5 67 -gradient[-1] xyz --sqr[-3--1] -+[-3--1] -+[-1] 1e-8 -sqrt[-1] -/[-4,-3] [-1] -/[-2,-1]
philpem@5 68 _gradient_orientation2 :
philpem@5 69 -gradient[-1] xy --sqr[-2,-1] -+[-2,-1] -+[-1] 1e-8 -sqrt[-1] -/[-3] [-1] -/[-2,-1]
philpem@5 70 _gradient_orientation1 :
philpem@5 71 -gradient[-1] x --abs[-1] -+[-1] 1e-8 -/[-2,-1]
philpem@5 72 gradient_orientation : -int ${1=3}
philpem@5 73 -v- -if $1 (4) --[-1] $1 -if @-1 -rm[-1]
philpem@5 74 -v+ -e "Compute $1-D gradient orientation of the last image." -v-
philpem@5 75 -t float -_gradient_orientation$1 -else -v+ -e "Invalid argument '$1', should be '{1,2,3}'." -q
philpem@5 76 -endif -else -v+ -e "Invalid argument '$1', should be '{1,2,3}'." -q
philpem@5 77 -endif -v+
philpem@5 78
philpem@5 79 # Compute image laplacian.
philpem@5 80 #-------------------------
philpem@5 81 #@gmic laplacian : (no args) : Compute Laplacian of the last image.
philpem@5 82 laplacian :
philpem@5 83 -e "Compute image laplacian of the last image."
philpem@5 84 -v- -t float -hessian[-1] xxyyzz -+[-3--1] -v+
philpem@5 85
philpem@5 86 # Compute oriented second derivative in the gradient direction.
philpem@5 87 #--------------------------------------------------------------
philpem@5 88 #@gmic gradient_2derivative : (no args) : Compute gradient-directed 2nd derivative of the last image.
philpem@5 89 gradient_2derivative :
philpem@5 90 -e "Compute gradient-directed 2nd derivative of the last image."
philpem@5 91 -v- -t float --gradient[-1] xyz -hessian[-4] xxxyxzyyyzzz
philpem@5 92 --sqr[-3] -*[-10,-1] --sqr[-2] -*[-7,-1] --sqr[-1] -*[-5,-1]
philpem@5 93 -*[-8,-7,-5] 2 -*[-8] [-3] -*[-8] [-2] -*[-7] [-3] -*[-7] [-1] -*[-5] [-2] -*[-5] [-1]
philpem@5 94 -+[-9--4] -sqr[-3--1] -+[-3--1] -+[-1] 1e-8 -/[-2,-1] -v+
philpem@5 95
philpem@5 96 # Difference of Gaussians.
philpem@5 97 #-------------------------
philpem@5 98 #@gmic dog : 'sigma1=2','sigma2=3' : Compute edges in the last image by using difference of gaussian-filtered images.
philpem@5 99 dog : -float ${1=2},${2=3}
philpem@5 100 -e "Compute edges in the last image by difference of gaussian-filtered images, with standard deviations $1 and $2."
philpem@5 101 -v- -t float --blur[-1] $1 -blur[-2] $2 --[-1,-2] -norm[-1] -v+
philpem@5 102
philpem@5 103 # Estimate isophote curvatures.
philpem@5 104 #------------------------------
philpem@5 105 #@gmic curvature : (no args) : Estimate isophote curvatures of the last image.
philpem@5 106 curvature :
philpem@5 107 -e "Estimate isophote curvatures of the last image."
philpem@5 108 -v- [-1]x2 -laplacian -mv[-1] -2 -gradient_2derivative --[-2,-1]
philpem@5 109 -mv[-1] -2 -gradient_norm -+[-1] 1e-8 -/[-2,-1] -v+
philpem@5 110
philpem@5 111 # Complex<->polar transform (the two last images give the real and imaginary parts).
philpem@5 112 #-----------------------------------------------------------------------------------
philpem@5 113 #@gmic complex2polar : (no args) : Compute complex->polar transform (two last images are real and imaginary parts).
philpem@5 114 complex2polar :
philpem@5 115 -e "Compute complex to polar transform."
philpem@5 116 -v- -t float -+[-2] 1e-8 --/[-1] [-2] -atan[-1] -sqr[-3,-2] -+[-3,-2] -sqrt[-2] -v+
philpem@5 117
philpem@5 118 #@gmic polar2complex : (no args) : Compute polar->complex transform (two last images are real and imaginary parts).
philpem@5 119 polar2complex :
philpem@5 120 -e "Compute polar to complex transform."
philpem@5 121 -v- -t float [-1] -cos[-2] -sin[-1] -*[-1] [-3] -*[-3,-2] --[-2] 1e-8 -v+
philpem@5 122
philpem@5 123 # Fourier transform viewer with centered log-module and centered argument.
philpem@5 124 #-------------------------------------------------------------------------
philpem@5 125 #@gmic display_fft : (no args) : Display Fourier transform of the last image with centered log-module and argument (eq. to '-dfft').
philpem@5 126 display_fft :
philpem@5 127 -e "Display Fourier transform of the last image."
philpem@5 128 -v- -t float -fft[-1] -complex2polar -translate[-2,-1] 50%,50%,50%,0,2 -log[-2] -n 0,255 -v+
philpem@5 129 dfft :
philpem@5 130 -display_fft
philpem@5 131
philpem@5 132 # Render a RGBA image over a user-defined background.
philpem@5 133 #----------------------------------------------------
philpem@5 134 #@gmic compose_rgba : (no args) : Render a RGBA image (last image) over a RGB background (penultimate image).
philpem@5 135 compose_rgba :
philpem@5 136 -e "Compose RGBA image with RGB background."
philpem@5 137 -v- --[-1] 255 -r[-1] 100%x100%x1x4x0 -+[-1] 255 -r[-1] [-2],[-2],[-2],4,0
philpem@5 138 -s[-1] v -a[-4--2] v -/[-1] 255 [-1] -negative -r[-4--1] 100%x100%x1x3
philpem@5 139 -*[-4,-1] -*[-2,-1] -+[-2,-1] -v+
philpem@5 140
philpem@5 141 # Render a RGBA image over a synthetic checkerboard background.
philpem@5 142 #--------------------------------------------------------------
philpem@5 143 #@gmic display_rgba : (no args) : Render a RGBA image (last image) over a synthetic background (eq. to '-drgba').
philpem@5 144 display_rgba :
philpem@5 145 -e "Render RGBA image over synthetic background."
philpem@5 146 -v- 2x2 -f[-1] 160,128,128,160 -mv[-1] -2 -r[-2] 16x16 -r[-2] [-1]x[-1]x1x3,0,2 -compose_rgba -v+
philpem@5 147 drgba :
philpem@5 148 -display_rgba
philpem@5 149
philpem@5 150 #-----------------------------
philpem@5 151 #
philpem@5 152 # Geometric filters
philpem@5 153 #
philpem@5 154 #-----------------------------
philpem@5 155
philpem@5 156 # Image array.
philpem@5 157 #-------------
philpem@5 158 #@gmic array : 'M=3,N=M' : Create a MxN array from the last image.
philpem@5 159 array : -int ${1=3},${2=$1}
philpem@5 160 -e "Create a $1x$2 array from last image."
philpem@5 161 -v- [-1]x$1 -rm[-1] -a[-$1--1] x [-1]x$2 -rm[-1] -a[-$2--1] y -v+
philpem@5 162
philpem@5 163 # Tiled array.
philpem@5 164 #-------------
philpem@5 165 #@gmic array_tile : 'M=3,N=M' : Create a MxN fade-tiled array from the last image.
philpem@5 166 array_tile : -int ${1=3},${2=$1}
philpem@5 167 -e "Create a $1x$2 fade-tiled array from the last image."
philpem@5 168 -v- --translate[-1] 50%x50%x1x1,2 -mv[-1] -2 -fade_diamond 80,90 -array $1,$2 -v+
philpem@5 169
philpem@5 170 # Mirror-tiled image.
philpem@5 171 #--------------------
philpem@5 172 #@gmic mirror_tile : 'N=2' : Create a NxN mirror-tiled version of the last image.
philpem@5 173 _mirror_tile :
philpem@5 174 [-1]x3 -mirror[-3,-1] x -mirror[-2,-1] y -a[-4,-3] x -a[-2,-1] x -a[-2,-1] y
philpem@5 175 mirror_tile : -int ${1=2}
philpem@5 176 -e "Create a $1x mirror-tiled version of the last image."
philpem@5 177 -v- -i[0] ($1) --[0] 1 -repeat @0 -_mirror_tile -done -rm[0] -v+
philpem@5 178
philpem@5 179 # Taquin puzzles.
philpem@5 180 #----------------
philpem@5 181 #@gmic taquin : 'M=4,N=M' : Create a MxN taquin puzzle from the last image.
philpem@5 182 _taquin :
philpem@5 183 -i @0 -rand[-1] @0,1 -*[-1] -1 -round[-1] 1 --[-1] 1 -reverse[@-1] -rm[-1]
philpem@5 184 taquin : -int ${1=4},${2=$1}
philpem@5 185 -e "Create $1x$2 taquin puzzle from the last image."
philpem@5 186 -v- -i[0] ($1) -*[0] $2 -split_tile $1,$2 -repeat 10 -_taquin -done -rm[0] -append_tile $1,$2 -v+
philpem@5 187
philpem@5 188 # Image grids.
philpem@5 189 #-------------
philpem@5 190 #@gmic grid : 'M=10,N=M' : Create a MxN grid version of the last image.
philpem@5 191 grid : -int ${1=10},${2=$1}
philpem@5 192 -e "Create $1x$2 grid version of the last image."
philpem@5 193 -v- -i[-2] $1x$2 -f[-2] 1 --translate[-2] -1,-1 --[-3,-1] -*[-2] -1
philpem@5 194 -+[-2] 1 --dimensions[-1] -s[-1] y -/[-4] $1 -/[-3] $2 (2) -a[-5--1] y
philpem@5 195 -round[-1] 1,-1 -r[-2] @-1 -s[-1] y -rm[-1] -*[-4] $1 -*[-3] $2 -a[-4--1] y -r[-2] @-1
philpem@5 196 (0;2) -a[-2,-1] y -r[-3] @-1 -rm[-1] -r[-1] [-2] -*[-2,-1] -v+
philpem@5 197
philpem@5 198 # Insert colored frames around image.
philpem@5 199 #------------------------------------
philpem@5 200 #@gmic frame : 'W=20,H=W,R=255,G=255,B=255' : Insert a WxH RGB-colored frame around the last image.
philpem@5 201 _framex :
philpem@5 202 -i 1,1,1,3 -f[-1] $2,$3,$4 -r[-1] $1,[-2],[-2],[-2],1 -i[-3] [-1] -a[-3--1] x
philpem@5 203 _framey :
philpem@5 204 -i 1,1,1,3 -f[-1] $2,$3,$4 -r[-1] [-2],$1,[-2],[-2],1 -i[-3] [-1] -a[-3--1] y
philpem@5 205 frame : -int ${1=20},${2=$1} -float ${3=255},${4=$3},${5=$4}
philpem@5 206 -e "Insert a $1x$2 frame with RGB color ($3,$4,$5) in the last image."
philpem@5 207 -v- -_framex $1,$3,$4,$5 -_framey $2,$3,$4,$5 -v+
philpem@5 208
philpem@5 209 # Draw a colored fuzzy frame around image.
philpem@5 210 #-----------------------------------------
philpem@5 211 #@gmic frame_fuzzy : 'W=20,H=W,fuzzyness=3,smoothness=3,R=255,G=255,B=255' : Draw a WxH RGB-colored fuzzy frame around the last image.
philpem@5 212 frame_fuzzy : -int ${1=20},${2=$1} -float ${3=5},${4=1},${5=255},${6=$5},${7=$6}
philpem@5 213 -e "Draw a $1x$2 fuzzy frame with RGB color ($5,$6,$7), fuzzyness $3 and smoothness $4 in the last image."
philpem@5 214 -v- -i[0] ($1;$2) -*[0] 2 1x1x1x3 -f[-1] $5,$6,$7 -r[-1] [-2] 100%x100%
philpem@5 215 -polygon[-1] 4,0,0,100%,0,100%,@{0,1},0,@{0,1},1,1
philpem@5 216 -polygon[-1] 4,0,0,@{0,0},0,@{0,0},100%,0,100%,1,1
philpem@5 217 -rm[0] -translate[-1] $1,$2,0,0,2 -spread $3 -blur[-1] $4 -_fade 50,80 -v+
philpem@5 218
philpem@5 219 # Polaroid effect.
philpem@5 220 #-----------------
philpem@5 221 #@gmic polaroid : 'W1=30,W2=120,W3=40' : Create polaroid from last image, with specified border sizes.
philpem@5 222 polaroid : -int ${1=30},${2=120},${3=40}
philpem@5 223 -e "Create polaroid effect from the last image with borders $1, $2 and $3."
philpem@5 224 -v- -frame $1,$1,255,255,255 [-1],$2,1,3 -f[-1] 255 -a[-2,-1] y
philpem@5 225 --dimensions[-1] -+[-1] $3 -+[-1] $3 --f[-2] -1 -r[-1] @{-2,0-1},1,3,0,0,1 -rm[-2]
philpem@5 226 -blur[-1] 5 -r[-2] [-1],0,0,1 -n[-1] 0,180 -or[-2,-1] -v+
philpem@5 227
philpem@5 228 # Drop shadow.
philpem@5 229 #-------------
philpem@5 230 #@gmic drop_shadow : '(no args) : Add a drop shadow behind the last image.
philpem@5 231 drop_shadow :
philpem@5 232 -e "Add a drop shadow behind the last image."
philpem@5 233 -v- --f[-1] 0 --[-1] 255 -r[-2,-1] 120%x120%x1x100%,0,0,1 -+[-1] 255 --blur[-1] 10 -translate[-3,-2] 10,10,0,0,1
philpem@5 234 -*[-2,-1] -n[-1] 0,255 -+[-2,-1] -v+
philpem@5 235
philpem@5 236 # Split into tiles.
philpem@5 237 #------------------
philpem@5 238 #@gmic split_tile : 'M=8,N=M' : Split last image into MxN regular tiles.
philpem@5 239 split_tile : -int ${1=8},${2=$1}
philpem@5 240 -e "Decompose last image into $1x$2 regular tiles."
philpem@5 241 -v- -i[0] ($1) -*[0] $2 -s[-1] x,$1 -s[-$1--1] y,$2 -r[-@0--1] [-@0],0 -rm[0] -v+
philpem@5 242
philpem@5 243 # Append tiles.
philpem@5 244 #--------------
philpem@5 245 #@gmic append_tile : 'M=8,N=M' : Append last MxN regular tiles together.
philpem@5 246 append_tile : -int ${1=8},${2=$1}
philpem@5 247 -e "Append last $1x$2 regular tiles together."
philpem@5 248 -v- -i[0] ($1) -*[0] $2 -a[-@0--1] y -s[-1] y,$1 -a[-$1--1] x -rm[0] -v+
philpem@5 249
philpem@5 250 # Rotate tiles.
philpem@5 251 #---------------
philpem@5 252 #@gmic rotate_tile : 'angle=5,M=8,N=M' : Apply MxN tiled-rotation effect on the last image.
philpem@5 253 rotate_tile : -float ${1=5} -int ${2=8},${3=$2}
philpem@5 254 -e "Apply $2x$3 tiled-rotation effect on the last image, with angle $1."
philpem@5 255 -v- -i[0] ($2) -*[0] $3 -split_tile $2,$3 -rotate[-@0--1] $1 -append_tile $2,$3 -v+
philpem@5 256
philpem@5 257 # Tiled shift.
philpem@5 258 #-------------
philpem@5 259 #@gmic shift_tile : 'amplitude=20,M=8,N=M' : Apply MxN tiled-shift effect on the last image.
philpem@5 260 shift_tile : -float ${1=20} -int ${2=8},${3=8}
philpem@5 261 -e "Apply $2x$3 tiled-shift effect on the last image, with amplitude $1."
philpem@5 262 -v- -t float $2x$3x1x2 -noise[-1] $1 -r[-1] [-2],[-2],1,2 -warp[-2] [-1],1,1,0 -rm[-1] -v+
philpem@5 263
philpem@5 264 #-----------------------------
philpem@5 265 #
philpem@5 266 # Deformation filters
philpem@5 267 #
philpem@5 268 #-----------------------------
philpem@5 269
philpem@5 270 # Spread pixel values.
philpem@5 271 #---------------------
philpem@5 272 #@gmic spread : 'dx=3,dy=dx,dz=0' : Spread last image pixel values randomly along x,y and z.
philpem@5 273 spread : -float ${1=3},${2=$1},${3=0}
philpem@5 274 -e "Spread pixel values of the last image with amplitudes ($1,$2,$3))."
philpem@5 275 -v- -t float 100%x100%x100%x1x3 -noise[-3] $1,0 -noise[-2] $2,0
philpem@5 276 -noise[-1] $3,0 -a[-3--1] v -warp[-2] [-1],1 -rm[-1] -v+
philpem@5 277
philpem@5 278 # Water effect.
philpem@5 279 #--------------
philpem@5 280 #@gmic water : 'amplitude=30,smoothness=1.5' : Apply water effect on the last image.
philpem@5 281 water : -float ${1=30},${2=1.5}
philpem@5 282 -e "Apply water effect on the last image, with amplitude $1 and smoothness $2."
philpem@5 283 -v- -t float 25%x25%x25%x1 -noise[-1] $1 -gradient[-1] xyz -+[-1,-2,-3]
philpem@5 284 -blur[-1] $2 -*[-1] 2 -warp[-2] [-1],1 -rm[-1] -v+
philpem@5 285
philpem@5 286 # Wave effect.
philpem@5 287 #-------------
philpem@5 288 #@gmic wave : 'amplitude=4,frequency=0.4' : Apply wave effect on the last image.
philpem@5 289 wave : -float ${1=4},${2=0.4}
philpem@5 290 -e "Apply wave effect on the last image, with amplitude $1 and frequency $2."
philpem@5 291 -v- -t float (1) -r[-1] [-2],[-2],1,1,0,0,1 -distance[-1] 1
philpem@5 292 -*[-1] $2 [-1] -cos[-2] -sin[-1] -a[-2,-1] v -*[-1] $1
philpem@5 293 -warp[-2] [-1],1 -rm[-1] -v+
philpem@5 294
philpem@5 295 # Linear blur.
philpem@5 296 #-------------
philpem@5 297 #@gmic blur_linear : 'amplitude=10,vx=1,vy=0' : Apply oriented linear blur on the last image.
philpem@5 298 _blur_linear :
philpem@5 299 --warp[-2] [-1],1,1,1 -*[-2] -1 -warp[-3] [-2],1,1,1 -+[-3,-1] -/[-2] 2 -*[-1] -1
philpem@5 300 blur_linear : -int ${1=10} -float ${2=1},${3=0}
philpem@5 301 -e "Apply linear blur on the last image, with amplitude $1 and orientation ($2,$3)."
philpem@5 302 -v- -t float 1x1x1x2 -f[-1] $2,$3 -r[-1] [-2],[-2],1,2 -repeat $1 -_blur_linear -done -rm[-1] -v+
philpem@5 303
philpem@5 304 # Radial blur.
philpem@5 305 #-------------
philpem@5 306 #@gmic blur_radial : 'amplitude=10,angle=0.5' : Apply radial blur on the last image.
philpem@5 307 _blur_radial :
philpem@5 308 --rotate[-1] @-2,-2,0 -*[-3] -1 -rotate[-2] @-3,-2,0 -*[-3] -1 -+[-2,-1] -/[-1] 2
philpem@5 309 blur_radial : -int ${1=10} -float ${2=0.5}
philpem@5 310 -e "Apply radial blur on the last image, with amplitude $1 and angle $2."
philpem@5 311 -v- -t float [-1] -i[-2] ($2) -repeat $1 -_blur_radial -+[-2] $2 -done -v+
philpem@5 312
philpem@5 313 # Zoom blur.
philpem@5 314 #-----------
philpem@5 315 #@gmic blur_zoom : 'amplitude=5,zoom_step=1.5' : Apply radial blur on the last image.
philpem@5 316 _blur_zoom :
philpem@5 317 --r[-1] @0%x@0%x@0%x100%,2 -r[-1] [-2],0,1,1 -+[-2,-1] -/[-1] 2
philpem@5 318 blur_zoom : -int ${1=5} -float ${2=1.5}
philpem@5 319 -e "Apply zoom blur on the last image, with amplitude $1 and step $2."
philpem@5 320 -v- -t float -i[0] ($2) -+[0] 100 -repeat $1 -_blur_zoom -done -rm[0] -v+
philpem@5 321
philpem@5 322 # Generic macro for applying a PDE flow.
philpem@5 323 #---------------------------------------
philpem@5 324 pde_flow :
philpem@5 325 -v- -t float -repeat $2 -if $1 [-1] -endif
philpem@5 326 $4 ${5*} ($3) --stats[-2] -r[-1] 1x2x1x1,0 -abs[-1] -stats[-1] -i (@{-1,1}) -rm[-2]
philpem@5 327 -+[-1] 0.1 -/[-2,-1] -*[-2] @-1 -rm[-1] -+[-2,-1] -done -v+
philpem@5 328
philpem@5 329 # Mean-curvature flow.
philpem@5 330 #---------------------
philpem@5 331 #@gmic meancurvature_flow : 'nb_iter=5, time_step=30, seq=0' : Apply iterations of the mean curvature flow on the last image.
philpem@5 332 _meancurvature_flow :
philpem@5 333 [-1]x2 -laplacian -mv[-1] -2 -gradient_2derivative --[-2,-1]
philpem@5 334 meancurvature_flow : -int ${1=5},${3=0} -float ${2=30}
philpem@5 335 -e "Apply $1 iterations of the mean curvature flow, with time step $2."
philpem@5 336 -pde_flow $3,$1,$2,-_meancurvature_flow
philpem@5 337
philpem@5 338 # Total variation flow.
philpem@5 339 #---------------------
philpem@5 340 #@gmic tv_flow : 'nb_iter=5, time_step=20, seq=0' : Apply iterations of the total variation flow on the last image.
philpem@5 341 _tv_flow :
philpem@5 342 [-1]x3 -laplacian -mv[-1] -3 -gradient_2derivative --[-3,-1] -gradient_norm -+[-1] 0.5 -r[-1] [-2] -/[-2,-1]
philpem@5 343 tv_flow : -int ${1=5},${3=0} -float ${2=20}
philpem@5 344 -e "Apply $1 iterations of the total variation flow, with time step $2."
philpem@5 345 -pde_flow $3,$1,$2,-_tv_flow
philpem@5 346
philpem@5 347 # Hurl noise.
philpem@5 348 #------------
philpem@5 349 #@gmic noise_hurl : 'amplitude' : Add hurl noise to the last image.
philpem@5 350 noise_hurl : -float ${1=10}
philpem@5 351 -e "Add hurl noise of amplitude $1% on the last image."
philpem@5 352 -v- --stats --f[-2] 0 -noise[-1] 10 -n[-1] @{-2,0,1} -rm[-2] 100%x100% -f[-1] -2
philpem@5 353 -noise[-1] $1,2 -threshold[-1] 0 -r[-1] [-2]
philpem@5 354 -*[-2] [-1] -*[-1] -1 -+[-1] 1 -*[-3,-1] -+[-2,-1] -v+
philpem@5 355
philpem@5 356 # Pixelize.
philpem@5 357 #----------
philpem@5 358 #@gmic pixelize : 'sx=30,sy=sx' : Pixelize the last image with specified scales ('sx' and 'sy' in 0..100).
philpem@5 359 pixelize : -float ${1=20},${2=$1}
philpem@5 360 -e "Pixelize last image with scales ($1%,$2%)."
philpem@5 361 -v- --dimensions[-1] -r[-2] $1%x$2%x1x3,2 -r[-2] @-1 -rm[-1] -v+
philpem@5 362
philpem@5 363 # Deforming filter.
philpem@5 364 #------------------
philpem@5 365 #@gmic deform : 'amplitude=10' : Apply random smooth deformation on the last image.
philpem@5 366 deform : -float ${1=10}
philpem@5 367 -e "Apply random smooth deformation on the last image, with amplitude $1."
philpem@5 368 -v- -t float 2%x2%x1x2 -noise[-1] $1 -r[-1] [-2],[-2],1,2,5
philpem@5 369 -warp[-2] [-1],1,1,1 -rm[-1] -v+
philpem@5 370
philpem@5 371 # Puzzle filter.
philpem@5 372 #---------------
philpem@5 373 #@gmic puzzle : (no args) : Apply puzzle effect on the last image.
philpem@5 374 puzzle :
philpem@5 375 -e "Apply puzzle effect on the last image."
philpem@5 376 -v- -t float [-1] -r[-1] 5%x5%x100%x100%x2 -noise[-1] 0.1 -r[-1] [-2] -rm[-2]
philpem@5 377 [-1]x2 -translate[-1] 1,1 --[-2,-1] -norm[-1] -threshold[-1] 0.01 -*[-1] -1
philpem@5 378 -+[-1] 1 -r[-1] [-2] -*[-1,-2] 10%x10%x10%x2 -noise[-1] 5,1
philpem@5 379 -r[-1] [-2],[-2],1,2,5 -warp[-2] [-1],1,1,1 -rm[-1] -v+
philpem@5 380
philpem@5 381 # Fish-eye.
philpem@5 382 #----------
philpem@5 383 #@gmic fish_eye : 'amplitude=250' : Apply Fish-eye effect on the last image.
philpem@5 384 fish_eye : -float ${1=250}
philpem@5 385 -e "Apply Fish-eye effect on the last image, with amplitude $1."
philpem@5 386 -v- -t float 2x2x1x2 -f[-1] -1,1,-1,1,-1,-1,1,1 -r[-1] [-2],[-2],1,2,3 [-1]
philpem@5 387 -norm[-2] -n[-2] 0,1 -cut[-2] 0,0.7 --[-2] 0.7 -*[-2] -$1 -r[-2] [-1]
philpem@5 388 -*[-2,-1] -warp[-2] [-1],1,1,1 -rm[-1] -v+
philpem@5 389
philpem@5 390 #-----------------------------
philpem@5 391 #
philpem@5 392 # Artistic filters
philpem@5 393 #
philpem@5 394 #-----------------------------
philpem@5 395
philpem@5 396 # Add strip shades along x or y.
philpem@5 397 #-------------------------------
philpem@5 398 #@gmic shade_stripes : 'frequency=5, direction=1' : Add horizontal or vertical shaded stripes on the last image.
philpem@5 399 _shade_stripes0 :
philpem@5 400 -v+ -e "Add horizontal shaded stripes on the last image, with frequency $1." -v- 1x100%
philpem@5 401 _shade_stripes1 :
philpem@5 402 -v+ -e "Add vertical shaded stripes on the last image, with frequency $1." -v- 100%
philpem@5 403 shade_stripes : -float ${1=5} -int ${2=1}
philpem@5 404 -v- -t float -n[-1] 0,255 -_shade_stripes$2 $1 -noise[-1] $1,2 -distance[-1] 1
philpem@5 405 -r[-1] [-2] -n[-1] 0.3,1.5 -*[-1,-2] -cut[-1] 0,255 -v+
philpem@5 406
philpem@5 407 # Add old-movie stripes.
philpem@5 408 #-----------------------
philpem@5 409 #@gmic stripesy : 'frequency=10' : Add vertical stripes on the last image.
philpem@5 410 stripesy : -float ${1=10}
philpem@5 411 -e "Add vertical stripes on the last image, with frequency $1."
philpem@5 412 -v- -t float -n[-1] 0,255 100% -noise[-1] $1,2 -*[-1] 255 -r[-1] [-2]
philpem@5 413 -*[-1] 0.15 -+[-1,-2] -cut[-1] 0,255 -v+
philpem@5 414
philpem@5 415 # Tetris effect.
philpem@5 416 #---------------
philpem@5 417 #@gmic tetris : 'scale=10' : Apply tetris effect of given size on the last image.
philpem@5 418 tetris : -float ${1=10}
philpem@5 419 -e "Apply tetris effect on the last image, with scale $1."
philpem@5 420 -v- -t float [-1] -r[-1] $1%x$1%x$1%x3x2 -n[-1] 0,255 -quantize[-1] 10
philpem@5 421 -r[-1] [-2] -rm[-2] -blur[-1] 2 -sharpen[-1] 300,1 -v+
philpem@5 422
philpem@5 423 # Damp patch effect.
philpem@5 424 #-------------------
philpem@5 425 #@gmic damp_patch : 'opacity=0.7' : Apply damp patch effect on the last image.
philpem@5 426 damp_patch : -float ${1=0.7}
philpem@5 427 -e "Apply damp patch effect on the last image, with opacity $1."
philpem@5 428 -v- -t float 100%x100% -f[-1] 1 -translate[-1] 2,2 -translate[-1] -1,-1
philpem@5 429 -plasma[-1] 3,0.3 -abs[-1] -blur[-1] 1 -cut[-1] 3%,15% -r[-1] [-2]
philpem@5 430 -n[-1] $1,1 -*[-1,-2] -v+
philpem@5 431
philpem@5 432 # Light patch effect.
philpem@5 433 #--------------------
philpem@5 434 #@gmic light_patch : 'darkness=0.9,lightness=1.7' : Apply light patch effect on the last image.
philpem@5 435 light_patch : -float ${1=0.9},${2=1.7}
philpem@5 436 -e "Apply light patch effect on the last image, with darkness $1 and lightness $2."
philpem@5 437 -v- -t float -n[-1] 0,255 2%x2% -noise[-1] 40 -r[-1] [-2],5 -cut[-1] 0,255
philpem@5 438 -n[-1] $1,$2 -*[-2,-1] -cut[-1] 0,255 -v+
philpem@5 439
philpem@5 440 # Mosaic pattern.
philpem@5 441 #----------------
philpem@5 442 #@gmic mosaic : 'density=0.2' : Add mosaic pattern to the last image.
philpem@5 443 mosaic : -float ${1=0.2}
philpem@5 444 -e "Add mosaic pattern on the last image, with density $1."
philpem@5 445 -v- -t float 100%x100%x1x1 -noise[-1] $1,2 -distance[-1] 1
philpem@5 446 -sharpen[-1] 10000 -*[-1] -1 -blur[-1] 0.5 -n[-1] 0.3,1 -r[-1] [-2] -*[-2,-1] -v+
philpem@5 447
philpem@5 448 # Sponge filter.
philpem@5 449 #---------------
philpem@5 450 #@gmic sponge : 'size=13' : Apply sponge filter on the last image with specified brush size.
philpem@5 451 _circle :
philpem@5 452 -i 1 -+[-1] 1 -r[-1] $1x$1x1x1x0,0,1 -distance[-1] 1 -n[-1] 0,1 -sqrt[-1] -cut[-1] 0.85,0.86 -*[-1] -1 -n[-1] 0,1
philpem@5 453 sponge : -int ${1=13}
philpem@5 454 -e "Apply sponge filter on the last image, with brush size $1."
philpem@5 455 -v- 100%x100%x1x1 -noise[-1] 20,2 -r[-1] [-2] -n[-1] 0,1 -*[-1,-2]
philpem@5 456 -_circle $1 -dilate[-2] [-1] -rm[-1] -v+
philpem@5 457
philpem@5 458 # Heart filter.
philpem@5 459 #--------------
philpem@5 460 #@gmic hearts : (no args) : Apply heart filter on the last image.
philpem@5 461 _heart9x7 :
philpem@5 462 -i 9x7 -f[-1] 0,1,1,0,0,0,1,1,0,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,1,0,0,0,0
philpem@5 463 hearts :
philpem@5 464 -e "Apply heart filter on the last image."
philpem@5 465 -v- 100%x100%x1 -noise[-1] 10,2 -r[-1] [-2] -n[-1] 0,1 -*[-1,-2] -_heart9x7
philpem@5 466 -mirror[-1] y -dilate[-2] [-1] -rm[-1] -v+
philpem@5 467
philpem@5 468 # Color ellipses.
philpem@5 469 #----------------
philpem@5 470 #@gmic color_ellipses : 'opacity=0.07' : Add random colored ellipses on the last image.
philpem@5 471 _color_ellipses :
philpem@5 472 -i 10 -f[-1] @{-2,0-9} -ellipse[-3] @-1 -rm[-1] -translate[-1] 0,1
philpem@5 473 color_ellipses : -float ${1=0.07}
philpem@5 474 -e "Add random colored ellipses to the last image, with opacity $1."
philpem@5 475 -v- --dimensions[-1] -r[-1] 2x2x1x1x0 -mirror[-1] x 1x400 -rand[-1] @{-2,0,1} --rand[-1] @{-2,2,3}
philpem@5 476 -rm[-3] 2x[-1] --dimensions[-4] -r[-1] 2x2x1x1x0 -s[-1] y
philpem@5 477 -+[-2,-1] -mirror[-1] x -rand[-2] @{-1,0,1} -rm[-1] -/[-1] 10 --rand[-1] -1,1
philpem@5 478 1x[-1] -f[-1] $1 3x[-1] -rand[-1] 10,255 -a[-6--1] x -repeat 400 -_color_ellipses -done -rm[-1] -v+
philpem@5 479
philpem@5 480 # Whirls texture.
philpem@5 481 #----------------
philpem@5 482 #@gmic whirls : (no args) : Add random whirl texture on the last image.
philpem@5 483 whirls :
philpem@5 484 -e "Add random whirl texture to the last image."
philpem@5 485 -v- -n[-1] 0,255 -t float [-1] -f[-1] 0 -noise[-1] 0.3,2 -blur[-1] 3
philpem@5 486 -gradient[-1] xyz -a[-3--1] v -norm[-1] -sqrt[-1] -blur[-1] 3 -gradient[-1] xyz
philpem@5 487 -a[-3--1] v -norm[-1] -sqrt[-1] -blur[-1] 3 -gradient[-1] xyz -a[-3--1] v
philpem@5 488 -norm[-1] -sqrt[-1] -blur[-1] 3 -gradient[-1] xyz -a[-3--1] v -norm[-1]
philpem@5 489 -sqrt[-1] -n[-1] 0.8,1.5 -r[-1] [-2] -*[-2,-1] -cut[-1] 0,255 -v+
philpem@5 490
philpem@5 491 # Add water reflection.
philpem@5 492 #----------------------
philpem@5 493 #@gmic reflect : (no args) : Add water reflection effect to the last image.
philpem@5 494 reflect :
philpem@5 495 -e "Add water reflection effect to the last image."
philpem@5 496 -v- -t float [-1] -mirror[-1] y -r[-1] 100%x100%x100%x3 -s[-1] v -*[-3] 0.8
philpem@5 497 -*[-2] 0.9 -a[-3--1] v -water 30,1.5 1x2 -f[-1] 1,0 -r[-1] [-2]x3 -*[-2,-1]
philpem@5 498 -a[-2,-1] y -v+
philpem@5 499
philpem@5 500 # B&W Edge filter.
philpem@5 501 #-----------------
philpem@5 502 #@gmic edges : 'threshold=30' : Estimate image contours of the last image.
philpem@5 503 edges : -float ${1=30}
philpem@5 504 -e "Estimate last image contours, with threshold $1."
philpem@5 505 -v- -t float [-1] -n[-1] 0,255 -gradient_norm -blur[-1] 0.5
philpem@5 506 -threshold[-1] $1% -distance[-1] 0 -equalize[-1] 256 -*[-1] -1 -n[-1] 0,255
philpem@5 507 -r[-1] [-2] -rm[-2] -v+
philpem@5 508
philpem@5 509 # Cartoon effect.
philpem@5 510 #----------------
philpem@5 511 #@gmic cartoon : 'threshold=30' : Apply cartoon effect on the last image.
philpem@5 512 cartoon : -float ${1=30}
philpem@5 513 -e "Apply cartoon effect on the last image, with threshold $1."
philpem@5 514 -v- -t float [-1]x2 -edges $1 -r[-2] 8x8x1x3,2 -r[-3] 100%x100%x100%x3
philpem@5 515 -rgb2lut[-3] [-2] -lut2rgb[-3] [-2] -rm[-2] -blur[-2] 2 -*[-2--1] -n[-1] 0,255 -v+
philpem@5 516
philpem@5 517 # Drawing effect.
philpem@5 518 #----------------
philpem@5 519 #@gmic drawing : (no args) : Apply drawing effect on the last image.
philpem@5 520 drawing :
philpem@5 521 -e "Apply drawing effect on the last image."
philpem@5 522 -v- -t float -smooth[-1] 200,0.2,1,3,3 -blur[-1] 2 -sharpen[-1] 1000 [-1]
philpem@5 523 -r[-2] 20x20x1x3,2 -equalize[-2] 256 -rgb2lut[-1] [-2],1 -lut2rgb[-1] [-2] -rm[-2] -v+
philpem@5 524
philpem@5 525 # Whirl drawing effect.
philpem@5 526 #----------------------
philpem@5 527 #@gmic draw_whirl : (no args) : Apply whirl drawing effect on the last image.
philpem@5 528 draw_whirl :
philpem@5 529 -e "Apply whirl drawing effect on the last image."
philpem@5 530 -v- -t float 100%x100% -noise[-1] 70,2 -*[-1] 255 -r[-1] [-2] -and[-1,-2] -smooth[-1] 100,0,1,2,2
philpem@5 531 -sqrt[-1] -n[-1] 0,255 -equalize[-1] 256 -v+
philpem@5 532
philpem@5 533 # Paper texture.
philpem@5 534 #---------------
philpem@5 535 #@gmic paper_texture : (no args) : Add paper texture to the last image.
philpem@5 536 paper_texture :
philpem@5 537 -e "Add paper texture to the last image."
philpem@5 538 -v- -t float [-1] 30%x30% -noise[-1] 1,2 -r[-1] [-2],[-2],[-2],1,0 -ifft[-1]
philpem@5 539 -rm[-1] -translate[-1] 50%x50%x50%x0x2 -sharpen[-1] 1 -n[-1] 1,1.2 -r[-1] [-2]
philpem@5 540 -*[-2,-1] -cut[-1] [-2],[-2] -rm[-2] -v+
philpem@5 541
philpem@5 542 # B&W Stencil filter.
philpem@5 543 #--------------------
philpem@5 544 #@gmic stencilbw : (no args) : Apply B&W stencil effect on the last image.
philpem@5 545 stencilbw :
philpem@5 546 -e "Apply B&W stencil effect on the last image."
philpem@5 547 -v- -r[-1] 100%x100%x1x100% -t float [-1] -edges 30 -quantize[-2] 3 -blur[-2] 10
philpem@5 548 -sharpen[-2] 1000000 -norm[-2] -n[-2] 0,1 -*[-1,-2] -n[-1] 0,255 -v+
philpem@5 549
philpem@5 550 # B&W Pencil filter.
philpem@5 551 #-------------------
philpem@5 552 #@gmic pencilbw : (no args) : Apply B&W pencil effect on the last image.
philpem@5 553 pencilbw :
philpem@5 554 -e "Apply B&W pencil effect on the last image." -v- -r[-1] 100%x100%x1x100%
philpem@5 555 -norm[-1] -blur[-1] 0.3 -sharpen[-1] 4000 -smooth[-1] 60,0,1 -equalize[-1] 256
philpem@5 556 -sqrt[-1] -n[-1] 0,255 -r[-1] 100%x100%x1x3 -v+
philpem@5 557
philpem@5 558 # B&W dithered filter.
philpem@5 559 #----------------------
philpem@5 560 #@gmic ditheredbw : (no args) : Create dithered B&W version of the last image.
philpem@5 561 ditheredbw :
philpem@5 562 -e "Create dithered B&W version of the last image." -v- -n[-1] 0,255
philpem@5 563 -r[-1] 100%x100%x100%x3 -i 2x1x1x3 -f[-1] 0,255 -rgb2lut[-2] [-1],1
philpem@5 564 -lut2rgb[-2] [-1] -rm[-1] -v+
philpem@5 565
philpem@5 566 # B&W dots effect.
philpem@5 567 #-----------------
philpem@5 568 #@gmic dotsbw : (no args) : Apply B&W dots effect on the last image.
philpem@5 569 dotsbw :
philpem@5 570 -e "Apply B&W dots effect on the last image."
philpem@5 571 -v- -t float -norm[-1] --r[-1] 10%x10%x1x1x2 [-1]x4 -threshold[-5] 10%
philpem@5 572 -threshold[-4] 30% -threshold[-3] 50% -threshold[-2] 70% -threshold[-1] 90%
philpem@5 573 -r[-5--1] [-6],4 -translate[-5--1] -5,-5 -rm[-6] -_circle 3 -dilate[-6] [-1]
philpem@5 574 -rm[-1] -_circle 5 -dilate[-5] [-1] -rm[-1] -_circle 7 -dilate[-4] [-1]
philpem@5 575 -rm[-1] -_circle 9 -dilate[-3] [-1] -rm[-1] -_circle 11 -dilate[-2] [-1]
philpem@5 576 -rm[-1] -or[-5--1] -n[-1] 0,255 -r[-1] 100%x100%x1x3 -v+
philpem@5 577
philpem@5 578 # Andy Warhol style.
philpem@5 579 #-------------------
philpem@5 580 #@gmic warhol : 'M=3,N=M' : Create a MxN Andy Warhol effect on the last image.
philpem@5 581 _warhol :
philpem@5 582 [-1] 6x1x1x1x3 -f[-3] 0,1,2,3,4,5 -n[-1] 0.2,0 -n[-3] 0,255 -f[-2,-1] 128 -noise[-2,-1] 60,0 -a[-3--1] v
philpem@5 583 -cut[-1] 0,255 -ycbcr2rgb[-1] -r[-1] 256x1x1x3,3 -sqr[-1] -n[-1] 0,255 -lut2rgb[-2] [-1] -rm[-1] -mv[-1] -2
philpem@5 584 warhol : -int ${1=3},${2=$1}
philpem@5 585 -e "Create a $1x$2 Andy Warhol effect on the last image."
philpem@5 586 -v- -t float -norm[-1] -blur[-1] 2 -quantize[-1] 6 -n[-1] 0,255
philpem@5 587 -i[0] ($1) -+[0] $2 -/[0] 2 -pow[0] -1 -*[0] 100 -round[0] 1,-1 -r[-1] @0%x@0%x1x1,2
philpem@5 588 -f[0] $1 -*[0] $2 -repeat @0 -_warhol -done -rm[0,-1] -append_tile $1,$2 -v+
philpem@5 589
philpem@5 590 # Cubism.
philpem@5 591 #--------
philpem@5 592 #@gmic cubism : 'nb_iter=160,bloc_size=30,max_angle=75,opacity=0.7,smoothness=0' : Apply cubism effect on the last image.
philpem@5 593 _cubism :
philpem@5 594 1x1x1x1x2 -rand[-2] 0,@{-3,0} -rand[-1] 0,@{-3,1} -a[-2,-1] x -round[-1] 1 --+[-1] $1 --[-2] $1
philpem@5 595 --crop[-4] @-2,@-1,1 -blur[-1] $4 --f[-1] 1 -rm[-3] 1 -rand[-1] -$2,$2 -rotate[-3,-2] @-1,0,0 -rm[-1]
philpem@5 596 -image[-5] [-2],@-3,0,$3,[-1] -rm[-3--1]
philpem@5 597
philpem@5 598 cubism : -int ${1=160},${2=30} -float ${3=75},${4=0.7},${5=0}
philpem@5 599 -e "Apply cubism effect on the last image, with $1 iterations, bloc size $2, maximum angle $3, opacity $4 and smoothness $5."
philpem@5 600 -v- --dimensions[-1] -repeat $1 -_cubism $2,$3,$4,$5 -done -rm[-1] -v+
philpem@5 601
philpem@5 602 # Soft glow.
philpem@5 603 #-----------
philpem@5 604 #@gmic glow : 'amplitude=3' : Apply glow effect on the last image.
philpem@5 605 glow : -float ${1=3}
philpem@5 606 -e "Apply glow effect on the last image, with amplitude $1."
philpem@5 607 -v- -t float -r[-1] 100%x100%x1x3 -rgb2ycbcr[-1] -s[-1] v --blur[-3] $1 -n[-1] [-4] -+[-4,-1] -/[-3] 2
philpem@5 608 -a[-3--1] v -ycbcr2rgb[-1] -v+
philpem@5 609
philpem@5 610 # Old photo filter.
philpem@5 611 #------------------
philpem@5 612 #@gmic old_photo : (no args) : Apply old photo effect on the last image.
philpem@5 613 old_photo :
philpem@5 614 -e "Apply old photo effect on the last image."
philpem@5 615 -v- -noise 20 -blur 1 -sharpen 30,1 -blur 0.8 -frame_fuzzy 20,20,6,3 -damp_patch 0.7 -n 0,255 -sepia -v+
philpem@5 616
philpem@5 617 #-------------------------
philpem@5 618 #
philpem@5 619 # Color filters
philpem@5 620 #
philpem@5 621 #-------------------------
philpem@5 622
philpem@5 623 # Compute luminance.
philpem@5 624 #-------------------
philpem@5 625 #@gmic luminance : (no args) : Compute luminance of the last image.
philpem@5 626 luminance :
philpem@5 627 -e "Compute luminance of the last image."
philpem@5 628 -v- -n[-1] 0,255 -r[-1] 100%x100%x1x3 -rgb2ycbcr[-1] -channels[-1] 0 -v+
philpem@5 629
philpem@5 630 # Apply a 3x3 transformation matrix to RGB vectors.
philpem@5 631 #---------------------------------------------------
philpem@5 632 #@gmic mix_rgb : a11,a12,a13,a21,a22,a23,a31,a32,a33 : Apply 3x3 specified matrix to RGB colors.
philpem@5 633 mix_rgb : -float ${1=1},${2=0},${3=0},${4=0},${5=1},${6=0},${7=0},${8=0},${9=1}
philpem@5 634 -e "Apply matrix [ $1 $2 $3 ; $4 $5 $6 ; $7 $8 $9 ] to RGB pixels of the last image."
philpem@5 635 -v- -t float -r[-1] 100%x100%x1x3,0,2 -s[-1] v
philpem@5 636 --*[-3] $4 --*[-3] $5 -+[-1,-2] --*[-2] $6 -+[-1,-2]
philpem@5 637 --*[-4] $7 --*[-4] $8 -+[-1,-2] --*[-3] $9 -+[-1,-2]
philpem@5 638 -*[-5] $1 -*[-4] $2 -*[-3] $3 -+[-5--3]
philpem@5 639 -a[-3--1] v -v+
philpem@5 640
philpem@5 641 # Solarize.
philpem@5 642 #----------
philpem@5 643 #@gmic solarize : (no args) : Apply solarization effect on the last image.
philpem@5 644 solarize :
philpem@5 645 -e "Apply solarization effect on the last image."
philpem@5 646 -v- -luminance -n[-1] 0,128 -lut2rgb[-1] 1 -v+
philpem@5 647
philpem@5 648 # Sepia filter.
philpem@5 649 #--------------
philpem@5 650 #@gmic sepia : (no args) : Apply sepia tones filter on the last image.
philpem@5 651 _sepia :
philpem@5 652 -i 6x1x1x3 -f[-1] 0,44,115,143,196,244,0,20,84,119,184,235,0,5,44,73,144,200 -r[-1] 256x1x1x3,3
philpem@5 653 sepia :
philpem@5 654 -e "Apply sepia tones filter on the last image."
philpem@5 655 -v- -luminance -_sepia -lut2rgb[-2] [-1] -rm[-1] -v+
philpem@5 656
philpem@5 657 # Negative.
philpem@5 658 #----------
philpem@5 659 #@gmic negative : (no args) : Compute negative of last image negative.
philpem@5 660 negative :
philpem@5 661 -e "Compute negative of the last image."
philpem@5 662 -v- -t float -*[-1] -1 [-1] -stats[-1] -c[-1] 0,0,0,0 -r[-1] [-2] --[-1,-2] -v+
philpem@5 663
philpem@5 664 # Select RGB pixels in an image.
philpem@5 665 #--------------------------------
philpem@5 666 #@gmic select_rgb : 'R=0,G=0,B=0,tolerance=10' : Select RGB colored pixels in the last image.
philpem@5 667 select_rgb :
philpem@5 668 -e "Select RGB color ($(1=0),$(2=0),$(3=0)) in the last image, with tolerance $(4=30)."
philpem@5 669 -v- 1x1x1x3 -f[-1] $1,$2,$3 -r[-1] [-2] --[-2,-1] -norm[-1] -threshold[-1] $4 -negative -v+
philpem@5 670
philpem@5 671 # Fill image with RGB color.
philpem@5 672 #---------------------------
philpem@5 673 #@gmic fill_rgb : 'R=0,G=0,B=0' : Fill last image with specified RGB color.
philpem@5 674 fill_rgb :
philpem@5 675 -e "Fill last image with RGB color ($(1=0),$(2=$1),$(3=$2))."
philpem@5 676 -dimensions[-1] ($1^$2^$3) -r[-1] @-2 -rm[-2]
philpem@5 677
philpem@5 678 #-------------------------
philpem@5 679 #
philpem@5 680 # Motion related filters
philpem@5 681 #
philpem@5 682 #-------------------------
philpem@5 683
philpem@5 684 # Cross-correlation and normalized cross-correlation.
philpem@5 685 #-----------------------------------------------------
philpem@5 686 #@gmic cross_correlation : (no args) : Compute cross-correlation between the two last images.
philpem@5 687 cross_correlation :
philpem@5 688 -e "Compute cross-correlation between the two last images."
philpem@5 689 -v- -t float -norm[-2,-1] -fft[-2] -fft[-1] [-2,-1] -mul[-2] [-5] -mul[-1] [-6]
philpem@5 690 --[-2,-1] -*[-5,-3] -*[-3,-2] -+[-3,-2] -ifft[-2,-1] -rm[-1] -v+
philpem@5 691
philpem@5 692 #@gmic normalized_cross_correlation : (no args) : Compute normalized cross-correlation between the two last images.
philpem@5 693 normalized_cross_correlation :
philpem@5 694 -e "Compute normalized cross-correlation between the two last images."
philpem@5 695 -v- -t float -norm[-2,-1] -fft[-2] -fft[-1] [-2,-1] -mul[-2] [-5] -mul[-1] [-6]
philpem@5 696 --[-2,-1] -*[-5,-3] -*[-3,-2] -+[-3,-2] [-2,-1] -a[-2,-1] v -norm[-1]
philpem@5 697 -/[-3] [-1] -/[-2,-1] -ifft[-2,-1] -rm[-1] -v+
philpem@5 698
philpem@5 699 # Phase correlation.
philpem@5 700 #-------------------
philpem@5 701 #@gmic phase_correlation : (no args) : Estimate translation vector between the two last images by the phase correlation method.
philpem@5 702 phase_correlation :
philpem@5 703 -e "Compute phase correlation between the two last images."
philpem@5 704 -v- -normalized_cross_correlation -stats[-1] -c[-1] 0,8,0,10 -r[-1] 1,1,1,3,-1 -v+
philpem@5 705
philpem@5 706 # Compute a morphing sequence (between the two latest images).
philpem@5 707 #-------------------------------------------------------------
philpem@5 708 #@gmic morph : 'N=10,smoothness=0.2' : Compute morphing sequence between the two latest images.
philpem@5 709 morph : -int ${1=10} -float ${2=0.2}
philpem@5 710 -e "Compute morphing sequence with $1 frames and smoothness $2."
philpem@5 711 -v- -t float -r[-1] [-2],3 [-2] -displacement[-1] [-2],$2
philpem@5 712 -warp[-3] [-1],1,1,1,$1 -*[-1] -1 -warp[-2] [-1],1,1,1,$1 -rm[-1]
philpem@5 713 -a[-$1--1] z -reverse -a[-$1--1] z
philpem@5 714 1x1x2 -f[-1] 0,1 -r[-1] [-2],3 -*[-2] [-1] -*[-1] -1 -+[-1] 1 -*[-3,-1]
philpem@5 715 -+[-2,-1] -s[-1] z -reverse[-$1--1] -v+
philpem@5 716
philpem@5 717 # Register two latest images with a rigid or non-rigid warp.
philpem@5 718 #------------------------------------------------------------
philpem@5 719 #@gmic register : 'method=0' : Register last image with the penultimate image ('method' can be '{0=translation, 1=non-rigid warp}').
philpem@5 720 _register1 :
philpem@5 721 -e "Align last and penultimate images with non-rigid warp."
philpem@5 722 -v- -t float -r[-1] [-2],3 [-1] -displacement[-1] [-3],1.2 -warp[-2] [-1],1 -rm[-1] -v+
philpem@5 723 _register0 :
philpem@5 724 -e "Align last and penultimate images with translation."
philpem@5 725 -v- -t float -r[-1] [-2],3 [-2,-1] -blur[-2,-1] 2 -equalize[-2,-1] 256 -phase_correlation -r[-1] [-2],[-2]
philpem@5 726 -warp[-2] [-1],1,1,2,1 -rm[-1] -v+
philpem@5 727 register : -int ${1=1}
philpem@5 728 -if $1 -_register1 -else -_register0 -endif
philpem@5 729
philpem@5 730 #-------------------------
philpem@5 731 #
philpem@5 732 # Video related filters
philpem@5 733 #
philpem@5 734 #-------------------------
philpem@5 735
philpem@5 736 # Deinterlace frame.
philpem@5 737 #-------------------
philpem@5 738 #@gmic deinterlace : 'method=0' : Deinterlace last image by a simple algorithm ('method' can be 0=simple or 1=motion-compensated).
philpem@5 739 _deinterlace0 :
philpem@5 740 -e "Deinterlace last image with simple method."
philpem@5 741 -v- -t float -k[-1] [-1] -s[-1] y -a[1--1:2] y -a[2--1] y -r[-1,-2] [-3]x5 -+[-1,-2]
philpem@5 742 -/[-1] 2 -rm[-2] -v+
philpem@5 743 _deinterlace1 :
philpem@5 744 -e "Deinterlace last image with motion-compensated method."
philpem@5 745 -v- -t float -k[-1] -s[-1] y -a[0--1:2] y -a[1--1] y -r[-2] [-1],0
philpem@5 746 -r[-1,-2] 100%x200%x1x100%x5 [-2] -displacement[-1] [-2]x0.01
philpem@5 747 -warp[-3] [-1],1,1,1,2 -*[-1] -1 -warp[-2] [-1],1,1,1,2 -rm[-1] -k[-2,-4] -+[-1,-2]
philpem@5 748 -/[-1] 2 -v+
philpem@5 749 deinterlace :
philpem@5 750 -_deinterlace${1=0]
philpem@5 751
philpem@5 752 # Predator effect. (first image must be the reference background, second image is the one to process).
philpem@5 753 #---------------------------------------------------------------------------------------------------
philpem@5 754 #@gmic predator : (no args) : Apply predator effect on the last image using background as the penultimate image.
philpem@5 755 predator :
philpem@5 756 -e "Apply predator effect on the last image."
philpem@5 757 -v- -t float -equalize[-2--1] 256 --[-1] [-2] -sqr[-1] -cut[-1] 20%,100%
philpem@5 758 -blur[-1] 1 -n[-1] 0,30 -channels[-1] 0,1 -warp[-2] [-1],1,1 -rm[-1] -v+
philpem@5 759
philpem@5 760 #-------------------------
philpem@5 761 #
philpem@5 762 # Other various filters
philpem@5 763 #
philpem@5 764 #-------------------------
philpem@5 765
philpem@5 766 # Horizontal fading.
philpem@5 767 #-------------------
philpem@5 768 #@gmic fade_x : 'start=30,end=70' : Create an horizontal fading transition between the two last images ('start' and 'end' in [0..100]).
philpem@5 769 _fade : -float ${1=30},${2=70}
philpem@5 770 -t float -r[-2] [-3],5 -r[-1] [-2],3 -cut[-1] $1%,$2% -n[-1] 0,1 --*[-1] -1 -+[-1] 1 -*[-4,-1] -*[-2,-1] -+[-2,-1]
philpem@5 771 fade_x :
philpem@5 772 -e "Create ($1%,$2%) horizontal fading transition between the two last images."
philpem@5 773 -v- 2 -f[-1] 0,1 -_fade $1,$2 -v+
philpem@5 774
philpem@5 775 # Vertical fading.
philpem@5 776 #-----------------
philpem@5 777 #@gmic fade_y : 'start=30,end=70' : Create a vertical fading transition between the two last images ('start' and 'end' in [0..100]).
philpem@5 778 fade_y : -float ${1=30},${2=70}
philpem@5 779 -e "Create ($1%,$2%) vertical fading transition between the two last images."
philpem@5 780 -v- 1x2 -f[-1] 0,1 -_fade $1,$2 -v+
philpem@5 781
philpem@5 782 # Radial fading.
philpem@5 783 #---------------
philpem@5 784 #@gmic fade_radial : 'start=30,end=70' : Create radial fading transition between the two last images ('start' and 'end' in [0..100]).
philpem@5 785 fade_radial : -float ${1=30},${2=70}
philpem@5 786 -e "Create ($1%,$2%) radial fading transition between the two last images."
philpem@5 787 -v- 100%x100% -point 50%,50%,0,1,1 -distance[-1] 1 -_fade $1,$2 -v+
philpem@5 788
philpem@5 789 # Diamond fading.
philpem@5 790 #----------------
philpem@5 791 #@gmic fade_diamond : 'start=70,end=90' : Create diamond-shaped fading transition between the two last images ('start' and 'end' in [0..100]).
philpem@5 792 fade_diamond : -float ${1=70},${2=90}
philpem@5 793 -e "Create ($1%,$2%) diamond-shaped fading transition between the two last images."
philpem@5 794 -v- 3x3 -f[-1] 0,1,0,1,1,1,0,1,0 -_fade $1,$2 -v+
philpem@5 795
philpem@5 796 # Image composition : try to generate an image containing all details of an image list.
philpem@5 797 # Usage : gmic image1.jpg -compose_add image2.jpg -compose_add ... imageN.jpg -compose_add -compose
philpem@5 798 #----------------------------------------------------------------------------------------------------
philpem@5 799 #@gmic compose_add : (no args) : Generate composition image from the last image (to be used with '-compose').
philpem@5 800 compose_add :
philpem@5 801 -e "Generate composition image."
philpem@5 802 -v- [-1] -gradient_norm -blur[-1] 2 -n[-1] 1,10 -sqr[-1] -s[-2] v -*[-4] [-1]
philpem@5 803 -*[-3] [-1] -*[-2] [-1] -a[-4--1] v -v+
philpem@5 804
philpem@5 805 #@gmic compose : (no args) : Compose images of the list togethers.
philpem@5 806 compose :
philpem@5 807 -e "Compose all images of the list togethers."
philpem@5 808 -v- -r [0],[0],1,4,0 -r [-1],3 -+ -s[-1] v -/[-4] [-1] -/[-3] [-1] -/[-2] [-1]
philpem@5 809 -rm[-1] -a v -v+
philpem@5 810
philpem@5 811 # Multiply composition.
philpem@5 812 #----------------------
philpem@5 813 #@gmic compose_multiply : (no args) : Compose the penultimate image with the last one, using multiply composition.
philpem@5 814 compose_multiply :
philpem@5 815 -e "Compose the penultimate image with the last one, using multiply composition."
philpem@5 816 -v- -t float -r[-1] 100%x100%x1x[-2] -r[-1] [-2],3 -/[-1] 255 -*[-2,-1] -v+
philpem@5 817
philpem@5 818 # Screen composition.
philpem@5 819 #---------------------
philpem@5 820 #@gmic compose_screen : (no args) : Compose the penultimate image with the last one, using screen composition.
philpem@5 821 compose_screen :
philpem@5 822 -e "Compose the penultimate image with the last one, using screen composition."
philpem@5 823 -v- -t float -r[-1] 100%x100%x1x[-2] -r[-1] [-2],3 -/[-1] 255
philpem@5 824 -*[-1] 1 -+[-1] 1 -*[-2] -1 -+[-2] 255 -*[-2,-1] -*[-1] -1 -+[-1] 255 -v+
philpem@5 825
philpem@5 826 # Overlay composition.
philpem@5 827 #---------------------
philpem@5 828 #@gmic compose_overlay : (no args) : Compose the penultimate image with the last one, using overlay composition.
philpem@5 829 compose_overlay :
philpem@5 830 -e "Compose the penultimate image with the last one, using overlay composition."
philpem@5 831 -v- -t float -r[-1] 100%x100%x1x[-2] -r[-1] [-2],3 -/[-1] 255
philpem@5 832 --threshold[-1] 0.5 --*[-3] 4 -+[-1] 510 -*[-1] [-3] --[-1] 255
philpem@5 833 -*[-4] 2 -+[-1] [-4] -*[-4,-3] -*[-3,-2] -+[-2,-1] -v+
philpem@5 834
philpem@5 835 # Print the factorial of an integer.
philpem@5 836 #-----------------------------------
philpem@5 837 #@gmic factorial : 'N' : Print the factorial of the integer 'N'.
philpem@5 838 factorial : -int $1
philpem@5 839 -v- ($1) -+[-1] 1 -if @-1 (1) (1) -repeat $1 -*[-1] @-2 -+[-2] 1 -done -v+ -e "Factorial($1) = @-1" -v- -rm[-3--1]
philpem@5 840 -else -echo "Factorial($1) is undefined." -q -endif -v+
philpem@5 841
philpem@5 842 # This is a sucking easter-egg ! (R-Rated).
philpem@5 843 #------------------------------------------
philpem@5 844 dick3d :
philpem@5 845 -e ""
philpem@5 846 -e "!!********************************************************!!"
philpem@5 847 -e "!! Congratulations ! You have found the hidden Easter-egg !!"
philpem@5 848 -e "!!********************************************************!!"
philpem@5 849 -e ""
philpem@5 850 -v- -rm -t float 2 1x2 1x1x2 -f -1,1 -r 100x100x100x1x3 -sqr -+ -* -8 -exp
philpem@5 851 [0]x2 -translate[-1] 20 -translate[-2] -20 -+[-1,-2] -translate[-1] 0,-20
philpem@5 852 -r[-2] 100x220x100x1x3 -r[-2] 100x100x100x3,0,0,1 -translate[-2] 0,10 -+
philpem@5 853 -isovalue3d 0.5 -rd3d 4 -d3d -v+
philpem@5 854
philpem@5 855 # Create 3D centered unit mapped cube from an image.
philpem@5 856 #---------------------------------------------------
philpem@5 857 #@gmic imagecube3d : 'resolution' : Create a 3D mapped cube from the last image.
philpem@5 858 imagecube3d : -int ${1=128}
philpem@5 859 -e "Create 3D mapped cube of size $1x$1x$1 from last image."
philpem@5 860 -v- -r[-1] $1,$1,1,-100,2 -mirror[-1] x -elevation3d[-1] 0 -c3d[-1] -n3d[-1] -+3d[-1] 0,0,0.5 --rot3d[-1] 0,1,0,180
philpem@5 861 -+3d[-2,-1] --rot3d[-1] 0,1,0,90 --rot3d[-2] 1,0,0,90 -+3d[-3--1] -v+
philpem@5 862
philpem@5 863 # Local Variables:
philpem@5 864 # mode: sh
philpem@5 865 # End:
philpem@5 866 #
philpem@5 867 # (End of G'MIC macro file)