MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: converting function from RasterArray to Raster

  • To: mathgroup at smc.vnet.net
  • Subject: [mg81924] Re: [mg81876] Re: converting function from RasterArray to Raster
  • From: "Ricardo Pietrobon" <pietr007 at mc.duke.edu>
  • Date: Sat, 6 Oct 2007 04:50:40 -0400 (EDT)
  • References: <200710050857.EAA00958@smc.vnet.net>

thanks a lot, it does work now.

On 10/5/07, Jun-Sok Huhh <anarinsk at gmail.com> wrote:
> I've just tested randomWalker. It worked fine with MATHEMATICA 6. RasterArray is automatically translated to Raster.
>
> Actually, there is one error in your uploaded code.
>
> randomWalkers[n_, p_, g_, m_, s_, r_, t _] :=
>
> "t _" has made non-functionality for me. "t_" worked fine.
>
>
> > Hi,
> >
> > I am new to mathematica and trying to convert a call
> > to RasterArray to
> > Raster in Mathematica 6.0.  The old function, which
> > used to work with
> > RasterArray was:
> >
> > m = Max[First[results]];
> > Show[GraphicsRow[(Graphics[
> >       RasterArray[Map[
> > If[#1 === 0, GrayLevel[1],
> > evel[1], GrayLevel[#1[[2]]/m]] &, #1, {2}]],
> > AspectRatio -> Automatic] &) /@
> > ] &) /@ {First[results],
> >     Last[results]}]]
> >
> >
> > Simply substituting RasterArray by Raster won't do
> > the trick, but the
> > debugger doesn't catch a syntatic problem.  Any
> > thoughts on how to get
> > the function to work with Raster would be
> > appreciated.
> >
> > Ricardo
> > Duke University
> > PS - By the way, the full code (which actually came
> > from the
> > Simulating Society book by Gaylord) is below:
> >
> >
> > randomWalkers[n_, p_, g_, m_, s_, r_, t _] :=
> > Module[{society, RND, k, walk, GN}, RND :=
> > := RandomInteger[{1, 4}];
> >    k = 0; society =
> > Table[Floor[p + RandomReal[]], {n}, {n}] /.1 :>
> > 1 :> {RND, ++k,
> > Floor[g + RandomReal[]], RandomInteger[{1, m},
> > {1, m}, s],
> >        RandomInteger[{0, r}]};
> > walk[{l, a___}, 0, _, _, _, {4, ___}, _, _, _, _,
> > _, _, _, _] := {RND,
> >       a}; walk[{l, a___},
> > 0, _, _, _, _, _, _, {2, ___}, _, _, _, _] :=
> > _] := {RND, a};
> > walk[{l, a___}, 0, _, _, _, _, _, _, _, {3, ___},
> > _}, _, _, _] := {RND,
> > a}; walk[{l, a___}, 0, _, _, _, _, _, _, _, _,
> > _, _, _, _, _] := 0;
> > walk[{2, a___}, _, 0, _, _, {3, ___}, _, _, _, _,
> > _, _, _, _] := {RND,
> >       a}; walk[{2, a___}, _,
> > 0, _, _, _, {1 ___}, _, _, _, _, _, _] := {RND,
> > {RND, a};
> > walk[{2, a___}, _, 0, _, _, _, _, _, _, _, {4,
> > {4, ___}, _, _] := {RND,
> > a}; walk[{2, a___}, _, 0, _, _, _, _, _, _, _,
> > _, _, _, _, _] := 0;
> > walk[{3, a___}, _, _, 0, _, _, {4, ___}, _, _, _,
> > _, _, _, _] := {RND,
> >       a}; walk[{3, a___}, _, _,
> > 0, _, _, _, {2, ___}, _, _, _, _, _] := {RND,
> > {RND, a};
> > walk[{3, a___}, _, _, 0, _, _, _, _, _, _, _, {1,
> > {1, ___}, _] := {RND,
> > a}; walk[{3, a___}, _, _, 0, _, _, _, _, _, _,
> > _, _, _, _, _] := 0;
> > walk[{4, a___}, _, _, _, 0, _, _, {1, ___}, _, _,
> > _, _, _, _] := {RND,
> >       a}; walk[{4, a___}, _, _, _,
> >      0, _, _, _, {3, ___}, _, _, _, _] := {RND, a};
> > walk[{4, a___}, _, _, _, 0, _, _, _, _, _, _, _,
> > _, {2, ___}] := {RND,
> > a}; walk[{4, a___}, _, _, _, 0, _, _, _, _, _,
> > _, _, _, _, _] := 0;
> > walk[{_, a___}, _, _, _, _, _, _, _, _, _, _, _,
> > _, _] := {RND, a};
> > walk[0, {3, ___}, {4, ___}, _, _, _, _, _, _, _,
> > _, _, _, _] := 0;
> > walk[0, {3, ___}, _, {1, ___}, _, _, _, _, _, _,
> > _, _, _, _] := 0;
> > walk[0, {3, ___}, _, _, {2, ___}, _, _, _, _, _,
> > _, _, _, _] := 0;
> > walk[0, _, {4, ___}, {1, ___}, _, _, _, _, _, _,
> > _, _, _, _] := 0;
> > walk[0, _, {4, ___}, _, {2, ___}, _, _, _, _, _,
> > _, _, _, _] := 0;
> > walk[0, _, _, {1, ___}, {2, ___}, _, _, _, _, _,
> > _, _, _, _] := 0;
> > walk[0, {3, a___}, _, _, _, _, _, _, _, _, _, _,
> > _, _] := {RND, a};
> > walk[0, _, {4, a___}, _, _, _, _, _, _, _, _, _,
> > _, _] := {RND, a};
> > walk[0, _, _, {1, a___}, _, _, _, _, _, _, _, _,
> > _, _] := {RND, a};
> > walk[0, _, _, _. {2, a___}, _, _, _, _, _, _, _,
> > _, _] := {RND, a};
> >    walk[0, _, _, _, _, _, _, _, _, _, _, _, _] := 0;
> >    GN[func_, lat_] :=
> >     MapThread[
> > func, (RotateRight[lat, #1] &) /@ {{0, 0}, {1,
> > , {1, 0}, {0, -1}, {-1,
> > 0}, {0, 1}, {1, -1}, {-1, -1}, {-1, 1}, {1,
> > 1}, {1, 1}, {2,
> >         0}, {0, -2}, {-2, 0}, {0, 2}}, 2];
> >    NestList[GN[walk, #1] &, society, t]];
> >
> > SeedRandom[2];
> > results = randomWalkers[100, 0.65, 1, 1, 1, 1,
> > 10000];
> >
>
>


-- 
Ricardo Pietrobon, MD, PhD, MBA
Associate Vice Chair and Assistant Professor, Department of Surgery
Director of Biomedical Informatics, Duke Translational Medicine Institute
http://www.dtmi.duke.edu/

my calendar is available at
http://www.google.com/calendar/embed?src=pietr007%40gmail.com&mode=WEEK
to view start and end times, click on the specific hyperlink and then
send me a time that best fits your schedule


  • Prev by Date: Re: Re: BarChart - intensity of colour increases up the
  • Next by Date: Re: Re: Can Integrate[expr, {x, a, b}] give an
  • Previous by thread: Re: converting function from RasterArray to Raster
  • Next by thread: Tooltips in ContourPlot