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

Home » Public Forums » archive » Re: Histogram shift
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
Re: Histogram shift [message #42707] Tue, 22 February 2005 06:35
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Michael Wallace writes:

> All in all, it's pretty cool stuff.

Indeed. :-)

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: Histogram shift [message #42710 is a reply to message #42707] Mon, 21 February 2005 22:44 Go to previous message
Michael Wallace is currently offline  Michael Wallace
Messages: 409
Registered: December 2003
Senior Member
> Well, do tell! We are starved for good news the past week
> or so. :-)

Well, if you really want to know about my world ...


I'd always hated setting hard values for VIEWPLANE_RECT because there
was invariably one case that'd throw a wrench into the works and cause
your once nice looking plot to look now like crap. For me, it was
always my Y axis that'd get pushed off the left side of the viewplane.
Given that you're using the same font sizes all the time, you can pretty
easily calculate the top and bottom of the viewplane. However, you
never really know where the left side is going to end up because the
positioning of the text is totally dependent on the length of the tick
mark strings on the Y axis. A longer string means your Y title is
further out. And if you ever decided that Courier looks better than
Helvetica, there you were having to redo the viewplane numbers.

Long story short, I created a function which takes in x and y data
vectors as well as title text strings, various fonts, dimensions and a
few other inputs and spits out an IDLgrWindow or IDLgrBuffer with the
appropriate view, models, IDLgrPlot, etc. stored in the GRAPHICS_TREE.
The VIEWPLANE_RECT is calculated based on the positioning of all the
graphics objects and so it's never too big or too small. Everything
fits just right. I've also now created an equivalent function for an
IDLgrImage rather than IDLgrPlot.


And since you're so starved, here's another one but it doesn't deal with
Object Graphics. I needed to to use the aforementioned plotting from
Java. I didn't want to use the IDL-Java Bridge because the Bridge is
clunky and the Bridge only goes one direction. You can instantiate a
Java virtual machine in IDL, but you can't instantiate an IDL session
from within Java. Anyway, I settled on the easy solution of having my
Java process spawn an IDL process. I could form the IDL commands within
Java and write the commands to the IDL process and let IDL do it's
thing. However, I had to send quite a bit of data across between Java
and IDL. Sending the data across the pipe would get very complex very
quickly and writing out the data to a file only to be read into IDL
could be time consuming. What I wound up doing was using shared memory
just as if you wanted to transfer data between two IDL processes. It's
quick because you don't hit the I/O subsystems of Java or IDL or of your
operating system and it's pretty easy to read and write directly to
memory. This solution worked like a champ. I thought it was pretty cool.

Now to wrap things up and put a nice bow on it all, I have a website
where I'm using Java to handle the back-end processing and dynamic
content. A user will go to the website and request certain data. A
Java program will then go and get the appropriate data from an Oracle
database and send the data on to IDL using the process above. IDL will
then create a plot or two (now with automatic viewplane sizing!) and
these images will be served back to the user. All the user knows is
that they click a button and they're taken to a page with their plots on
it. And in a typical case, it only takes a couple seconds for ALL of
this to happen. Naturally, complex plots or querying over huge data
ranges will make it slow down, but it's not bad for on-the-fly plot
creation.

All in all, it's pretty cool stuff.

-Mike
Re: Histogram shift [message #42711 is a reply to message #42710] Mon, 21 February 2005 19:50 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Michael Wallace writes:

> I've already been doing that. Nevertheless, I managed to have a great
> IDL Object Graphics victory over the weekend and I'm not about to embark
> on another epic journey back into the bowels of the language so soon.
> There are some laurels that need to be rested on first! :-)

Well, do tell! We are starved for good news the past week
or so. :-)

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Re: Histogram shift [message #42712 is a reply to message #42711] Mon, 21 February 2005 19:07 Go to previous message
Michael Wallace is currently offline  Michael Wallace
Messages: 409
Registered: December 2003
Senior Member
> I thought the whole point of object graphics was that
> you could do anything you wanted to do if you were
> willing to spend enough time with inadequate documentation
> to do it?

I've already been doing that. Nevertheless, I managed to have a great
IDL Object Graphics victory over the weekend and I'm not about to embark
on another epic journey back into the bowels of the language so soon.
There are some laurels that need to be rested on first! :-)


> P.S. I don't have any ideas about how to do this in
> object graphics. About a fourth of my book is about
> how to do it in direct graphics. Presumably some of
> those techniques could be extended to object graphics.

What you lined out was about the only think I could think of -- rolling
your own histogram drawing routine. There might come a day when I try
such a thing, but today's not the day -- I need to get comfy with those
laurels and get my energy back. :-)

-Mike
Re: Histogram shift [message #42714 is a reply to message #42712] Mon, 21 February 2005 17:39 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Michael Wallace writes:

> Okay, another object graphics question for everyone. Is there an easy
> way to shift a histogram over such that the bars are left justified with
> the data point rather than having the bars centered on the data point?
>
> I realize that I could shift the data itself and then draw the
> histogram, but there's a voice in the back of my mind that tells me
> "you're gonna shoot yourself in the foot, kid." Is there some other way
> to left justify the plot?

I thought the whole point of object graphics was that
you could do anything you wanted to do if you were
willing to spend enough time with inadequate documentation
to do it?

Cheers,

David

P.S. I don't have any ideas about how to do this in
object graphics. About a fourth of my book is about
how to do it in direct graphics. Presumably some of
those techniques could be extended to object graphics.

Here is the relevant part of the code:

; Calculate the histogram.

histdata = Histogram(image, Binsize=binsize, Max=Max(image), $
Min=Min(image))

; Have to fudge the bins and histdata variables to get the
; histogram plot to make sense.

npts = N_Elements(histdata)
halfbinsize = binsize / 2.0
bins = Findgen(N_Elements(histdata)) * binsize + Min(image)
binsToPlot = [bins[0], bins + halfbinsize, bins[npts-1] + binsize]
histdataToPlot = [histdata[0], histdata, histdata[npts-1]]
xrange = [Min(binsToPlot), Max(binsToPlot)]

; Plot the histogram of the display image. Axes first.

Plot, binsToPlot, histdataToPlot, $
Background=backcolor, $
Charsize=thisCharsize, $
Color=axiscolor,
Max_Value=max_value, $
NoData=1, $
Position=histoPos, $
Title='Image Histogram', $
XRange=xrange, $
XStyle=1, $
XTickformat='(I6)', $
XTitle='Image Value', $
YMinor=1, $
YRange=[0,max_value], $
YStyle=1, $
YTickformat='(I6)', $
YTitle='Pixel Density', $
_Extra=extra

; Overplot the histogram data in the data color.

OPlot, binsToPlot, histdataToPlot, PSym=10, Color=dataColor

; Make histogram boxes by drawing lines in data color.

FOR j=1L,N_Elements(bins)-2 DO BEGIN
PlotS, [bins[j], bins[j]], [!Y.CRange[0], histdata[j] < max_value], $
Color=dataColor
ENDFOR

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Maximze a minimize GUI
Next Topic: Re: /YNOZERO

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

Current Time: Sat Oct 11 11:46:44 PDT 2025

Total time taken to generate the page: 0.48529 seconds