My imagemagick version is 6.3.0 and my OS is Debian.
Grab this image:
http://jjfoerch.com/bitbucket/gliders.png
The following code works as expected using p{n,n} syntax. I added in a -sample 400% to make the output nice and big.
results: http://jjfoerch.com/bitbucket/gliders_ok.png
Code: Select all
neighbors='(p{i-1,j-1} + p{i,j-1} + p{i+1,j-1} + p{i-1,j} + p{i+1,j} + p{i-1,j+1} + p{i,j+1} + p{i+1,j+1})'
rules="(($neighbors<5) | ($neighbors>6) | ($neighbors==6 & u==1)) ? 1.0 : 0.0"
convert gliders.png -channel R -fx "$rules" -channel BG -fx R -sample 400% gliders_ok.png
But if I change the p{n,n} codes to the equivalent p[n,n] codes, the resulting image does not come out as expected.
results: http://jjfoerch.com/bitbucket/gliders_bad.png
Code: Select all
neighbors='(p[-1,-1] + p[0,-1] + p[1,-1] + p[-1,0] + p[1,0] + p[-1,1] + p[0,1] + p[1,1])'
rules="(($neighbors<5) | ($neighbors>6) | ($neighbors==6 & u==1)) ? 1.0 : 0.0"
convert gliders.png -channel R -fx "$rules" -channel BG -fx R -sample 400% gliders_bad.png