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

Home » Public Forums » archive » Re: Median filter the hard way
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Median filter the hard way [message #36727 is a reply to message #36726] Tue, 21 October 2003 15:52 Go to previous messageGo to previous message
Dick Jackson is currently offline  Dick Jackson
Messages: 347
Registered: August 1998
Senior Member
"JD Smith" <> wrote in message
news:pan.2003.10.17.22.22.14.73337.24537@as.arizona.edu...
> On Fri, 17 Oct 2003 14:34:30 -0700, Dick Jackson wrote:
>
>> Here's an array, a:
>>
>> IDL> a=Float(Byte(RandomU(seed,7,7)*10)) IDL>
a[2:4,2:4]=!values.F_nan
>
> [...]
>
>> The Convol function can be used to count up neighborhoods. If you
need
>> better counting around the edge, you could pad the array before
calling
>> Convol.
>>
>> IDL> print,Convol(Finite(a),Replicate(1B,3,3))
>
> Looks good, Dick. CONVOL's a bit heavy-handed for just counting: I'd
use
> smooth instead:
>
> IDL> print,smooth(finite(a)*9,3,/EDGE_TRUNCATE)
>
> [...]
>
> Notice it treats edges better (as far as this problem is concerned),

Granted, if edge pixels are not going to be dropped anyway for having
too few 'good' neighbors...

> and should definitely be faster.

A good guess, but in this case, I guess Convol can keep everything as
Byte type and it is indeed faster:

IDL> a=Float(Byte(RandomU(seed,2000,2000)*10))
IDL> tstart&b=Convol(Finite(a),Replicate(1B,3,3))&treport
0.510 seconds.
IDL> tstart&b=Convol(Finite(a),Replicate(1B,3,3))&treport
0.510 seconds.
IDL> help,b
B BYTE = Array[2000, 2000]
IDL> tstart&b=smooth(finite(a)*9,3,/EDGE_TRUNCATE)&trepor t
0.681 seconds.
IDL> tstart&b=smooth(finite(a)*9,3,/EDGE_TRUNCATE)&trepor t
0.661 seconds.
IDL> help,b
B INT = Array[2000, 2000]

You may want these for testing:

=====

PRO TStart, msg ; Timer Start
; Save current time for use by TReport
COMMON Timer, t0
IF N_Elements(msg) NE 0 THEN Print, msg
t0 = SysTime(1)
END

PRO TReport, msg ; Timer Report
; Print elapsed time since last TStart
COMMON Timer, t0
IF N_Elements(msg) EQ 0 THEN msg = ''
Print, Format='(A0, D10.3," seconds.")', msg, SysTime(1)-t0
END

=====

Cheers,
--
-Dick

Dick Jackson / dick@d-jackson.com
D-Jackson Software Consulting / http://www.d-jackson.com
Calgary, Alberta, Canada / +1-403-242-7398 / Fax: 241-7392
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: A complicate problem for building a map
Next Topic: MAP_IMAGE and Postscript

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

Current Time: Sat Oct 11 06:54:53 PDT 2025

Total time taken to generate the page: 2.55433 seconds