BookmarkSubscribeRSS Feed
Choose Language Hide Translation Bar
Craige_Hales

Staff

Joined:

Mar 21, 2013

Disorganization

 Playing with a square matrix of random numbers between zero and one. I was hoping for a more dynamic video; the rules in the loop settle into a fairly stable image in just a few thousand iterations...I threw away more than 8,000 of the 10,000 images at the end. The goal of the angle calculations in the loop is to look at points a little ways forward in the circle to determine the fate of the current point. The two videos are identical, except for the forward/reverse sequence of the frames. Forward is the order they are generated in, starting random and ending less random. Reverse ends in random data. The most interesting features are the thin rainbow bands created by the spectral color theme and the heatmap function. It takes many seconds to generate each frame; set the scale to .25 to speed it up.

 

dir = "D:\Chales\random\";
pad=5;
scale=1;
bitmap = J( 1200*scale +2*pad+1, 1200*scale + 2*pad + 1, Random Uniform( 0, 1 ) );//randomnormal(.5,1));//
New Window( "random", holder = H List Box( New Image( "rgb", {bitmap, bitmap, bitmap} ) ) );
nnn = 2e6;
For( i = 1, i <= 10000, i++, 
    (holder << child) << delete;
    bitmapt = bitmap[pad :: (N Rows( bitmap ) - pad), pad :: N Cols( bitmap ) - pad];
    img = New Image( Heat Color( bitmapt, "spectral" ) );
    img << saveImage( dir || "p" || Char( nnn ) || ".png", "png" );
    nnn += 1;
    holder << append( img );
    holder << updatewindow;
    Print( i );
    Wait( .02 );
    Parallel Assign(
        {thresholdx = Mean( bitmap ), source = bitmap, nr = N Rows( bitmap ), nc = N Cols( bitmap ), rmid = N Rows( bitmap ) / 2, cmid =
        N Cols( bitmap ) / 2, rate = .96, speed = 100, power=.1},
        bitmap[r, c] = If(
            angle = ATan( r - rmid, c - cmid );
            radius = Sqrt( (c - cmid) ^ 2 + (r - rmid) ^ 2 );
            angle = angle - speed / (radius ^ power);
            rr = ((rmid + Sin( angle ) * radius));
            If(
                rr < 2, rr = 2,
                rr > nr - 1, rr = nr - 1
            );
            cc = ((cmid + Cos( angle ) * radius));
            If(
                cc < 2, cc = 2,
                cc > nc - 1, cc = nc - 1
            );
           // show(rr,cc);
            Try( Sum( source[rr - 1 :: rr + 1, cc - 1 :: cc + 1] ) / 9 < thresholdx, Show( rr, cc ) );
        , 
            Max( 0, source[r, c] * rate )
        ,
            Min( 1, source[r, c] / rate )
        )
    );
);
Print( "done" );

 

 

Article Tags
Labels