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

Home » Public Forums » archive » Multidimensional Histograms re-visited
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Multidimensional Histograms re-visited [message #522] Sat, 05 September 1992 14:30 Go to previous message
jjb is currently offline  jjb
Messages: 3
Registered: July 1991
Junior Member
In article <27AUG199209562770@stars.gsfc.nasa.gov> you write:
> In article <1992Aug27.075540@highwire.gsfc.nasa.gov>,
> burel@highwire.gsfc.nasa.gov (Jonathan Burelbach) writes...
>
>> Help! I am trying to create a scatterplot of 2 Landsat Image bands (ie
>> band 4 vs band 5) for clustering purposes and I need to be able to determine
>> the density of points on the plot. I have tried to create a 256x256 z array
>> by looping through the images, but this takes forever with images of any
>> size. Does anyone have any suggestions?
>
> This may do what you want. It uses HISTOGRAM to cut down on some of the
> looping.
>
> Bill Thompson
> ------------------------------------------------------------ -------------------
> PRO FORM_HISTO2,X,Y,HISTO,XSTEPS,YSTEPS,XDELTA,YDELTA

(code here left out)


If I understand the intent of the question and the response, I think there
is a cleaner and simpler way to do this. I have imbedded this technique
in several codes so I don't have a stand alone routine to offer, but what
follows is an outline of the technique:

x = array of x values
y = array of y values
minx = minimum x value for x histogram axis
maxx = maximum x value for x histogram axis
miny = ditto for y etc.
maxy = ditto for y etc.
nx = number of histogram bins on the x axis
ny = number of histogram bins on the y axis


IDL code in outline form:

(Note: I usually deal with integer data for this problem so you
might want to pay attention to rounding issues here more than
I have....)

ix=long(nx*(x-minx)/(maxx-minx))
iy=long(ny*(y-miny)/(maxy-miny))
good=where((ix ge 0) and (ix lt nx) and (iy ge 0) and (iy lt ny))

(If good(0) eq -1 quit at this point....)

ixy=ix(good)+(iy(good)*nx)

hist=histogram(ixy,min=0l,max=nx*ny-1,binsize=1)

hist=reform(hist,nx,ny)



And we are done. Note that there is no looping at all!!!
Hope this helps.

Jeff Bloch
Space Astronomy and Astrophysics Group
Los Alamos National Laboratory
[Message index]
 
Read Message
Read Message
Previous Topic: Re: New IDL Prices!
Next Topic: Help: Coding iterative algorithm elimimating loops in IDL/PV~WAVE

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

Current Time: Wed Oct 08 15:58:02 PDT 2025

Total time taken to generate the page: 0.00523 seconds