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

Home » Public Forums » archive » Re: Today's IDL Lesson
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: Today's IDL Lesson [message #61922] Thu, 14 August 2008 13:27 Go to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
d.rowenhorst@gmail.com writes:

> Yeah - I learned a little bit ago that anytime that you are looping
> over a where function to pull out individual regions, a histogram with
> reverse_indices is going to going to get the job done much faster

I guess the lesson I learned is that I am pretty much
never going to use LABEL_REGION without also using
HISTOGRAM. In fact, because you have to also muck
around with LABEL_REGION to get good results, I
am going to write my own function that does all this
all at once! Look for it soon in the Coyote Library. :-)

This would make a *perfect* object, and you
don't even have to save the image. All you need
is the REVERSE_INDICES from the Histogram and the
size of the image and you can easily reconstitute
the image if and when you need it.

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming (www.dfanning.com)
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: Today's IDL Lesson [message #61924 is a reply to message #61922] Thu, 14 August 2008 12:27 Go to previous messageGo to next message
d.rowenhorst@gmail.co is currently offline  d.rowenhorst@gmail.co
Messages: 10
Registered: August 2008
Junior Member
On Aug 14, 3:05 pm, David Fanning <n...@dfanning.com> wrote:
> Folks,
>
> A couple of weeks ago I was give some IDL code to,
> essentially, find blobs in a large image, do some
> processing on them, and return a result image. The
> images we want to work on are on the order of
> 8800 by 6800, pretty big.
>
> Naturally, the code contained FOR loops coming out
> the wazzoo and it was VERY slow. I don't know *how*
> slow because I turned the computer off when I noticed
> smoke coming out the back and I couldn't immediately
> locate the damn fire extinguisher.
>
> Because lousy code doesn't necessarily prevent you
> from writing scientific papers about your algorithm,
> I read the paper to get the gist and decided their
> algorithm was overly complicated and that I could do
> it a lot more simply (and in WAY fewer loops).
>
> So I code it up, using a much smaller image subset,
> and it was quicker than snot. When I thought I had
> all the kinks worked out of it, I decided to give'er
> a try on the larger images. It took about 48 minutes
> to run. Humm. Odd.
>
> But I couldn't immediately see where the problem was.
> I decided to play tennis instead of work on it anymore. :-)
>
> This morning I ran the PROFILER on the code, and saw it
> was spending most of its time in the WHERE function.
> I was using the WHERE to locate the indices of blobs I
> wanted to work with from the LABEL_REGION image. A couple
> of quick tests showed that as that as that image gets larger,
> the search time of WHERE goes up exponentially.
>
> "Humm, I wish LABEL_REGION just returned the indices like the
> HISTOGRAM function does," I thought.
>
> What!? After 20 years of working with IDL it finally sunk
> in. What I need is a HISTOGRAM!!!!
>
> Here is the bottom line. My program, which took 48 minutes
> to run yesterday, takes 10 *seconds* to run today.
>
> Sometimes you just gotta love IDL! :-)
>
> Cheers,
>
> David
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming (www.dfanning.com)
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")

Yeah - I learned a little bit ago that anytime that you are looping
over a where function to pull out individual regions, a histogram with
reverse_indices is going to going to get the job done much faster
Re: Today's IDL Lesson [message #62058 is a reply to message #61922] Tue, 19 August 2008 13:35 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
David Fanning writes:

> This would make a *perfect* object, and you
> don't even have to save the image. All you need
> is the REVERSE_INDICES from the Histogram and the
> size of the image and you can easily reconstitute
> the image if and when you need it.

As promised, I put a new object up on my web page today,
named BLOB_ANALYZER to make it easier to do some of this
blob processing I've been talking about. It is sort of
a combination of LABEL_REGION, HISTOGRAM, FIND_BOUNDARY
and FIT_ELLIPSE. It can not only get blob indices quickly,
but it can perform various analysis functions on those
blobs.

Having said that, this is version 0.9 I guess, as I didn't
have time to incorporate some of the neat features Ben Tupper
showed me in one of his similar programs. I did steal some
of his best ideas, though, and I plan to incorporate more
features if and when I need them. In particular, I do NOT
store the actual image in my object, since I am working with
large images, and I don't want to carry around this overhead.
That restriction limits some of the things I can do. But if
you need a feature, ask. Ben will be happy to point out how
it can be done correctly. :-)

If you decide to give the Blob Analyzer a try, be sure you
also download a new version of Fit_Ellipse. Previous versions
of Fit_Ellipse were not thinking about memory usage, and that
has become a priority for me now. So this was rewritten to
have a MUCH smaller memory footprint (and a new, essential
keyword).

http://www.dfanning.com/ip_tips/blobanalsis.html
http://www.dfanning.com/programs/blob_analyzer__define.pro
http://www.dfanning.com/programs/fit_ellipse.pro

Feedback is always appreciated. Just be sure to SHOUT LOUDLY. :-)

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: question on destroying objarr's
Next Topic: Re: FOR loops removal

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

Current Time: Wed Oct 08 17:03:51 PDT 2025

Total time taken to generate the page: 0.00851 seconds