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

Home » Public Forums » archive » In Praise of HISTOGRAM
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
In Praise of HISTOGRAM [message #30253] Fri, 12 April 2002 10:00
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Folks,

I used to think the WHERE function was pretty neat. But
lately (I.e., this morning) I have become a convert and
sing in praise of the HISTOGRAM function.

I had as a task to compute a density plot from two
images. This is a pixel-wise comparison in which the
X axis contains the values of image 1 (0 to 255) and the Y axis
contains the values of image 2 (0 to 255). The Z direction of the
plot contains the number of times these two images have this same
pair-wise relationship. In other words, if the pixel value of image 1
is 10 and the pixel value of image 2 is 20, how many pixels are
there that have 10 in image 1 and 20 in image 2.

Because I had never done this before, I proceeded in my
usual plodding way. My first attempt (which I thought was
pretty slick) computed histograms of the two images and
used reverse indices to obtain the indices of the images
that contained a particular value. Then I did a set intersection
between the two vectors of indices to find out how many were
in common. This method took only 48 minutes on these rather
large (2199 x 2380) images. :-(

Oh, dear. I heard that ENVI did this sort of think almost
instantaneously. Didn't *anyone* download that SAVE file
cracker of Craig's!?

My colleague, Dave Burridge, and I put our heads together.
There must be a trick to be discovered here.

Hang on a minute! What if we create an integer array, put
one image in the low bits and the other image in the high
bits. Won't each pixel have a unique number value? Then,
what if we take a histogram of that? Won't that give us
a vector of 2^16-1 values? And what if we reform that
into the 256 by 256 array we are looking for?

Wham, bam. Less than 0.3 seconds later there was the
result! If that first time through hadn't have taken
48 minutes I wouldn't have believed it.

I don't know if I've ever said this before, but I
LOVE IDL!

Cheers,

David

--
David W. Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
[Message index]
 
Read Message
Previous Topic: Re: TVRD, Decomposed = ? and 24bit display
Next Topic: Re: ROUTINE_INFO problems

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

Current Time: Fri Oct 10 04:49:33 PDT 2025

Total time taken to generate the page: 0.40155 seconds