4 ms·
Translated to J for fun. NB.Iterated Function Systems require'viewmat' S=:640 640 NB.pixel sizes I=:S$0 NB.a matrix for image
by jxy 10y ago
Translated to J for fun.
NB.Iterated Function Systems
require'viewmat'
S=:640 640 NB.pixel sizes
I=:S$0 NB.a matrix for image
pl=:4 :0
'o s'=.2{.x NB.origin and size
p=.<.0.5+S*s%~y-o NB.convert y to pixel coordinate
if.+./(p<0),(p>S)do.return.else.I=:1(<p)}I end.
)
tr=:3 :0
200000 tr y
:
I=:S$0
im=.+/ .*,&1
'l k'=._2{.y NB.probabilities and corresponding transformations
p=.1 1
while.x do.
y pl p=.p im~k{~l I.?0
x=.<:x
end.
viewmat|.|:I NB.make first index horizontal and start from bottom left
)
NB.IFS=:origin;size;prob;trans
barnsley=:_2.25 _0.5;5 11;0.84 0.91 0.98 1;4 2 3$,_&".;._2[0 :0
0.85 0.04 0.00 _0.04 0.85 1.60
_0.15 0.28 0.00 0.26 0.24 0.44
0.20 _0.26 0.00 0.23 0.22 1.60
0.00 0.00 0.00 0.00 0.16 0.00
)
tr barnsley NB.takes one second 8-(
- cedricbonhomme 10y agonice!