MathGroup Archive 2007

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

Search the Archive

Re: Slow Manipulate with image argument

  • To: mathgroup at smc.vnet.net
  • Subject: [mg79228] Re: [mg79200] Slow Manipulate with image argument
  • From: Chris Hill <chill at wolfram.com>
  • Date: Sat, 21 Jul 2007 04:33:59 -0400 (EDT)
  • References: <200707200807.EAA00773@smc.vnet.net>

At 03:07 AM 7/20/2007, Maarten van der Burgt wrote:
>Dear all,
>
>
>
>
>
>Consider the lines of code below:
>
>
>
>dat =Table[Sin[x y/2],{x,-10,10,0.04},{y,-10,10,0.04}];
>
>gr=ArrayPlot[dat];
>
>h=Length[dat];
>w =Length[dat[[1]]];
>
>Manipulate[
>GraphicsColumn[{Show[{gr,Graphics[{Green,Line
>[{{0,h-i},{w,h-i}}]}]}],ListPlot[dat[[i]],PlotJoined->True,PlotRange->
>{-1,1}]}],
>{{i,200},1,h,1}]
>
>
>In the code above I generate a quite large array with data (= dat; in my
>real application dat is an image of similar size which I want to analyze).
>
>
>I generate an ArrayPlot (gr) of the data.
>
>
>Using Manipulate I want to show the data in each line of the array using
>ListPlot.
>
>
>It would help the analysis if in the same Manipulate window I could show
>the image with a line drawn on top of it, indicating which line of the
>array is shown in the ListPlot.
>
>
>This all works, but, since the graphics needs to be updated every time,
>Manipulate becomes very slow.
>
>
>Has anyone a bright idea how to speed this up, or to write this slightly
>different with the same (but faster) result?
>
>
>Thanks for your help,
>
>
>Maarten

This version is faster than your original:

Manipulate[
  Column[{Graphics[First[gr],
     Epilog -> {Green, Line[Dynamic[{{0, h - i}, {w, h - i}}]]},
     ImageSize -> 300, Sequence @@ Rest[gr]],
    Dynamic[ListPlot[dat[[i]], PlotJoined -> True, ImageSize -> 300,
      PlotRange -> {-1, 1}]]}], {{i, 200}, 1, h, 1}]

I used Column instead of GraphicsColumn and I wrapped Dynamic around 
the parts of the graphic that are dependent on the Manipulate 
parameter so that the entire graphic doesn't need to be reassembled 
every time the slider is moved (those parts that depend on i are 
updated in place).

Chris Hill
Wolfram Research 



  • Prev by Date: Re: graphing frequency & amplitude?
  • Next by Date: Re: Slow Manipulate with image argument
  • Previous by thread: Slow Manipulate with image argument
  • Next by thread: Re: Slow Manipulate with image argument