comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Diplay 2D data
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Diplay 2D data [message #57095] Tue, 04 December 2007 02:26 Go to next message
lasse is currently offline  lasse
Messages: 48
Registered: February 2007
Member
Hi there,

in one of the recent posts there was a link to Brian Larsen's homepage
and in particular his imagesc.pro. This reminded me that I wanted to
ask a question related to the matter of image display with axes:

What's the best way to display 2D colour-coded data with axes and what-
not? Or rather, what do people out there use?

For a long time I used a routine called IMDISP which I downloaded
somewhere. It seems to be the same approach as Brian's, getting a 2D
array, using one of the TV commands to display it at a certain
position and the overplotting axes. I am not happy with that approach
because axes and image are completely unconnected, if I change the
axes ranges then I (or the display routine) needs to chop of bits of
the image array, otherwise the same image is displayed just with
different axes. More importantly, both mentioned routines cannot pad
zeros to the image such that the axis range is extended over the
extends of the image. This is important for me because I am anal and I
want my dynamic spectra plots to start at round times - but the data
doesn't. And also, since the pixels have finite dimensions, I really
also need to change the axes values to the exact position at the end
of the pixel.

This then led me to write my own routine which uses POLYFILL. So
basically every pixel is drawn as a filled polygon with a certain
colour. This allows me to easily (in my mind) change the ranges
without having to fiddle with the data.

However, not only is a FOR loop with POLYFILL slow but also a page of
three dynamic spectra with 8000x128 points now easily makes a 40MB
PostScript - not surprisingly, really.

So to get back to the original question: How do other people display
2D data?

Cheers
Lasse Clausen
Re: Diplay 2D data [message #57155 is a reply to message #57095] Wed, 05 December 2007 01:05 Go to previous messageGo to next message
lasse is currently offline  lasse
Messages: 48
Registered: February 2007
Member
On 4 Dec, 20:43, pgri...@gmail.com wrote:
> Hi,
>
> I just want to point out that there exists an implementation in the
> solarsoft library (which admittedly require the whole library
> to be installed, as it calls many other routines) called spectro_plot,
> which also allows for logarithmic axis (which I think is a nice
> feature,
> and not easy to implement from scratch).

Well, using the POLYFILL approach you don't need to worry about that.
The PLOT, /NODATA, /YLOG command plots the coordinate system and then
POLYFILL figures out where to place the pixel, how high it is and so
on and so on. No fiddling with the original data required by the user,
IDL takes care of it.

Actually, I'm quite happy with my approach. I don't need to worry
about any padding, cropping, rebinning, logarithmic axis etc - which
is nice. The PostScript files get quite big, admittedly, but I can
gzip them, reducing the size by a factor of 15-20 as ps files are
ASCII files. In Windows I can still just double click on the .ps.gz
and GsView decompresses it automatically. And if need be the ps's are
readily converted to png to make them even smaller.

As I said, I just wanted to know what other people use.

Cheers
Lasse
Re: Diplay 2D data [message #57168 is a reply to message #57095] Tue, 04 December 2007 12:52 Go to previous messageGo to next message
Brian Larsen is currently offline  Brian Larsen
Messages: 270
Registered: June 2006
Senior Member
> I just want to point out that there exists an implementation in the
> solarsoft library (which admittedly require the whole library
> to be installed, as it calls many other routines) called spectro_plot,
> which also allows for logarithmic axis (which I think is a nice
> feature,
> and not easy to implement from scratch). As an example, if you create
> an image and axis with:
>
> n=200
> m=500
> im=dist(n,m)
> x=findgen(n)+10
> y=findgen(m)+10
>
> the plot resulting from
>
> spectro_plot,im,x,y,xrange=[-100,300],yrange=[1,800],/ylog,/ no_ut,/
> xstyle,/ystyle
>
> is exactely what you would expect from a plot-compatible image
> displayer such as the quick & dirty
>
> contour,im,x,y,xrange=[-100,300],yrange=[1,800],/ylog,/xstyl e,/ystyle,/
> fill,levels=indgen(256)/255.*max(im)
>
> but faster and without the artifacts & smoothing from the contouring.
> Mind the /no_ut keyword, though.



Arg, I use solarsoft all the time and haven't used that routine and it
seems great.

Brian

------------------------------------------------------------ --------------
Brian Larsen
Boston University
Center for Space Physics
Re: Diplay 2D data [message #57170 is a reply to message #57095] Tue, 04 December 2007 12:43 Go to previous messageGo to next message
pgrigis is currently offline  pgrigis
Messages: 436
Registered: September 2007
Senior Member
Hi,

I just want to point out that there exists an implementation in the
solarsoft library (which admittedly require the whole library
to be installed, as it calls many other routines) called spectro_plot,
which also allows for logarithmic axis (which I think is a nice
feature,
and not easy to implement from scratch). As an example, if you create
an image and axis with:

n=200
m=500
im=dist(n,m)
x=findgen(n)+10
y=findgen(m)+10

the plot resulting from

spectro_plot,im,x,y,xrange=[-100,300],yrange=[1,800],/ylog,/ no_ut,/
xstyle,/ystyle

is exactely what you would expect from a plot-compatible image
displayer such as the quick & dirty

contour,im,x,y,xrange=[-100,300],yrange=[1,800],/ylog,/xstyl e,/ystyle,/
fill,levels=indgen(256)/255.*max(im)

but faster and without the artifacts & smoothing from the contouring.
Mind the /no_ut keyword, though.

Cheers,
Paolo Grigis


Brian Larsen wrote:
>> I use Craig Markwardt's PLOTIMAGE (http://cow.physics.wisc.edu/~craigm/idl/graphics.html
>> ) which
>> mostly allows one to use the PLOT syntax for displaying images. It
>> allows the image range (e.g. IMGXRANGE) to be different from the plot
>> range (XRANGE), but I don't think it performs the zero padding you are
>> looking for. --Wayne
>
> Amazing what you learn when you read this newsgroup, I didn't know
> about that function. I will study it and see if I can improve imagesc
> in some way (or if I should just use plotimage)
>
> Brian
>
> ------------------------------------------------------------ --------------
> Brian Larsen
> Boston University
> Center for Space Physics
Re: Diplay 2D data [message #57171 is a reply to message #57095] Tue, 04 December 2007 12:13 Go to previous messageGo to next message
Brian Larsen is currently offline  Brian Larsen
Messages: 270
Registered: June 2006
Senior Member
> I use Craig Markwardt's PLOTIMAGE (http://cow.physics.wisc.edu/~craigm/idl/graphics.html
> ) which
> mostly allows one to use the PLOT syntax for displaying images. It
> allows the image range (e.g. IMGXRANGE) to be different from the plot
> range (XRANGE), but I don't think it performs the zero padding you are
> looking for. --Wayne

Amazing what you learn when you read this newsgroup, I didn't know
about that function. I will study it and see if I can improve imagesc
in some way (or if I should just use plotimage)

Brian

------------------------------------------------------------ --------------
Brian Larsen
Boston University
Center for Space Physics
Re: Diplay 2D data [message #57174 is a reply to message #57095] Tue, 04 December 2007 11:12 Go to previous messageGo to next message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
>
> So to get back to the original question: How do other people display
> 2D data?
>
I use Craig Markwardt's PLOTIMAGE ( http://cow.physics.wisc.edu/~craigm/idl/graphics.html
) which
mostly allows one to use the PLOT syntax for displaying images. It
allows the image range (e.g. IMGXRANGE) to be different from the plot
range (XRANGE), but I don't think it performs the zero padding you are
looking for. --Wayne
Re: Diplay 2D data [message #57216 is a reply to message #57095] Thu, 06 December 2007 02:36 Go to previous message
lasse is currently offline  lasse
Messages: 48
Registered: February 2007
Member
On 5 Dec, 19:23, pgri...@gmail.com wrote:
> May I ask what is the practical limit in the size of image (in, say,
> megapixel)
> for using this approach before it gets too slow? I agree that your
> idea is
> easier and simpler for small images, but I don't think it works on
> large
> images, because of the overhead of calling polyfill so many times...
>
> Ciao,
> Paolo

Ay caramba, these results are a bit shocking though not surprising.

When using a 300x200 array of random numbers, the difference in
runtime is about 200, something of the order of some milliseconds for
tvscl and just below one second for POLY_FILL. File size is ~3MB vs 64
KB. For a 3000x2000 image the runtime ratio is about 30 (POLY_FILL
takes 90 seconds to complete) and file size is ~294MB vs 6MB.

My spectra are of the order of 4000x100 and take 5 seconds to write as
PostScript.

Cheers
Lasse
Re: Diplay 2D data [message #57291 is a reply to message #57155] Wed, 05 December 2007 11:23 Go to previous message
pgrigis is currently offline  pgrigis
Messages: 436
Registered: September 2007
Senior Member
Lasse Clausen wrote:
> On 4 Dec, 20:43, pgri...@gmail.com wrote:
>> Hi,
>>
>> I just want to point out that there exists an implementation in the
>> solarsoft library (which admittedly require the whole library
>> to be installed, as it calls many other routines) called spectro_plot,
>> which also allows for logarithmic axis (which I think is a nice
>> feature,
>> and not easy to implement from scratch).
>
> Well, using the POLYFILL approach you don't need to worry about that.
> The PLOT, /NODATA, /YLOG command plots the coordinate system and then
> POLYFILL figures out where to place the pixel, how high it is and so
> on and so on. No fiddling with the original data required by the user,
> IDL takes care of it.
>
> Actually, I'm quite happy with my approach. I don't need to worry
> about any padding, cropping, rebinning, logarithmic axis etc - which
> is nice. The PostScript files get quite big, admittedly, but I can
> gzip them, reducing the size by a factor of 15-20 as ps files are
> ASCII files. In Windows I can still just double click on the .ps.gz
> and GsView decompresses it automatically. And if need be the ps's are
> readily converted to png to make them even smaller.

May I ask what is the practical limit in the size of image (in, say,
megapixel)
for using this approach before it gets too slow? I agree that your
idea is
easier and simpler for small images, but I don't think it works on
large
images, because of the overhead of calling polyfill so many times...

Ciao,
Paolo

>
> As I said, I just wanted to know what other people use.
>
> Cheers
> Lasse
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Off Topic UNIX Question
Next Topic: Build a dll within IDL

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 19:59:58 PDT 2025

Total time taken to generate the page: 0.00847 seconds