[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Plot into an array



In article <MPG.15a62d86f1dbe18d989e18@news.frii.com>,
 david@dfanning.com (David Fanning) wrote:

> Dominik Paul writes:
> 
> > does somebody know, how I can plot a function into an array, not into a
> > window? Or can I get the array of the image of a window for saving as a jpeg
> > or gif?
> 
> Write into a pixmap window (a window in memory):
> 
>    Window, /Pixmap, /Free
>    Plot, myfunction
>    array = TVRD() ; or TVRD(True=1) on 24-bit display
> 

Warning: if you plan to do this repeatedly, and/or with very large 
windows, TVRD() from graphics or pixmap windows is surprisingly slow, 
even for pixmaps.  (this from the IDL profiler; I once tried this on a 
large looped calculation involving geolocation of satellite instrument 
pixels, polyfilling the vertices, tvrd()'ing to an array, then summing 
the arrays to estimate the spatial field of view - in all of that, the 
tvrd() was by and large the bottleneck, not the math)

IIRC, David's suggestion below of using the Z buffer is more efficient 
(don't know why) and greatly reduced the bottleneck, though I could be 
wrong...

> Or, write into the Z-graphic buffer, if you want
> to be assured of having a 2D array:
> 
>    thisDevice = !D.Name
>    Set_Plot, 'Z'
>    Plot, myfunction
>    array = TVRD()
>    Set_Plot, thisDevice
>