Re: Slow Manipulate with image argument
- To: mathgroup at smc.vnet.net
- Subject: [mg79220] Re: Slow Manipulate with image argument
- From: Mariusz Jankowski <mjankowski at usm.maine.edu>
- Date: Sat, 21 Jul 2007 04:29:51 -0400 (EDT)
- References: <f7pqi0$1a8$1@smc.vnet.net>
Maarten, the main culprit is ListPlot so the idea is to disable it while the slider is moving (see ControlActive in documentation). gr = Import["http://www.ee.usm.maine.edu/courses/ele489/data/boats.tif"] dat = gr[[1, 1]] ; Here is the code with some other minor adjustments to your original: DynamicModule[{}, Column[{Row[{VerticalSlider[Dynamic[x], {1, h}], Show[{gr, Graphics[{Red, Dynamic[Line[{{1, x}, {w, x}}]]}]}]}, Spacer[10]], Panel[Dynamic[ ControlActive[Graphics[], ListPlot[dat[[Round[x]]], Filling -> Axis, PlotStyle -> None]]]]}, Alignment -> Center]] Bye, Mariusz 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 > > > > > > > > > > > > > >