\(\(\( (*\ 
      Temporal\ Color\ Changes\ in\ a\ Stack\ of\ Images\ Containing\ Randomly\ Generated\ Colors\ *) \)\(
\)\( (*\ 
      Copyright\ May1, \ 2006, \ 
      Doug\ Youvan, \ \(www . youvan . com\  &\)\ www . pseudocolor . 
          com\ *) \)\(\ \ \)\(
\)\(
\)\( (*\ Initialize\ *) \)\(
\)\(
\)\(numtimes = 4; \ numchannels = 3; \ width = 320; \ height = 240;

    \(numpoints = 
        numtimes*numchannels\ *width*
          height;\)

 (*\ 
      Make\ random\ one\ dimensional\ list\ with\ three\ significant\ places\ between\ zero\ and\ one; \ 
      length\ numpoints\ *) 


    \(rs = 
        Table[Random[Real, {0, 1}, numchannels], {i, 1, 
            numpoints}];\)

 (*\ 
      Partition\ \(out : \ numchannels\), \ width, \ 
      height\ *) 


    \(partpix = 
        Partition[Partition[Partition[rs, numchannels], width], 
          height];\)

    rs =. 

 (*\ 
      Segregate\ four\ random\ color\ images\ for\ display\ only; \ 
      partpix\ dimesnions\ are\ {4, 240, 320, 3}\ *) 


    \(timeonergb = partpix[\([1, All, All, All]\)];\)

    \(Show[Graphics[RasterArray[Apply[RGBColor, timeonergb, {2}]]], 
        ImageSize -> {640, 480}];\)\ \ 

    timeonergb =. \ \ \ \ \ \ \  (*\ expunged\ *) 


    \(timetworgb = 
        partpix[\([2, All, All, {1, 2, 3}]\)];\)

    \(Show[Graphics[RasterArray[Apply[RGBColor, timetworgb, {2}]]], 
        ImageSize -> {640, 480}];\)\ \ \ \ \ \ \ \ 

    \ timetworgb =. 


    \(timethreergb = 
        partpix[\([3, All, All, {1, 2, 3}]\)];\)

    \(Show[Graphics[RasterArray[Apply[RGBColor, timethreergb, {2}]]], 
        ImageSize -> {640, 480}];\)\ \ \ \ \ \ \ \ \ 

    timethreergb =. 


    \(timefourrgb = 
        partpix[\([4, All, All, {1, 2, 3}]\)];\)

    \(Show[Graphics[RasterArray[Apply[RGBColor, timefourrgb, {2}]]], 
        ImageSize -> {640, 480}];\)\ \ \ \ \ \ \ \ \ 

    timefourrgb =. 

 (*\ \ Make\ an\ all\ black\ background, \ 
      indexed\ by\ width\ and\ height\ *) 


    \(numpixels = width*height*3;\)

    \(colorover\  = 
        Table[{h, w, c}, {h, 1, height}, \ {w, 1, width}, \ {rgb, 1, 
            3}];\)

    \(colorover[\([All, All, All]\)] = 0. ;\)

 (*\ 
      Pick\ out\ pixels\ that\ get\ increasingly\ bluer\ in\ the\ blue\ channel\ over\ time, \ greener\ in\ the\ green, \ 
      and\ redder\ in\ the\ red, \ respectively\ ; \ uses\ partpix, \ 
      created\ before\ images\ were\ expunged\ *) 


    \(For[c = 1, c ≤ numchannels, \(c++\), 
        For[w = 1, w < width, \(w++\), 
          For[h = 1, 
            h < height, \(h++\), 
If[\((partpix[\([4, h, w, 
                      c]\)]\  > partpix[\([3, h, w, c]\)]\  > \ 
                  partpix[\([2, h, w, c]\)]\  > \ 
                  partpix[\([1, h, w, 
                      c]\)])\), 
colorover[\([h, w, 
                    c]\)]\  = 
                1\ \ ]\ \ \ \ \ ]]];\)


    Show[Graphics[RasterArray[Apply[RGBColor, colorover, {2}]]], 
      ImageSize -> {640, 480}]

    colorover =. 

    \)\)\)