Re: "Max()" filter? [message #29576 is a reply to message #29574] |
Thu, 07 March 2002 00:45   |
Dick Jackson
Messages: 347 Registered: August 1998
|
Senior Member |
|
|
"Dick Jackson" <dick@d-jackson.com> wrote in message
news:Neth8.6463$Qq1.33877@shaw-ty2...
> I'd like a filter that uses the Max() function, so that this array:
>
> 1 4 2 4 3
> 3 5 2 1 4
> 5 7 4 3 1
> 3 5 1 1 2
> 3 1 2 3 1
>
> filtered with width 3 gives:
>
> 5 5 5 4 4
> 7 7 7 4 4
> 7 7 7 4 4
> 7 7 7 4 3
> 5 5 5 3 3
>
> (I think! :-)
Sorry for answering my own posting, but something at this late hour reminded
me that this sounds like a Dilate kind of thing. (maybe my pupils are
dilating! :-) Sure enough, it's just the Grayscale Dilate operation. Have to
be careful around the edges, padding with a ring of zeros, removing it
afterward.
If you're curious, it's all described in online help for Dilate, but here's
how it works (sorry for the terse code):
IDL> z0=byte(10*randomu(seed,5,5))
IDL> print,z0
0 3 6 7 3
4 1 0 4 5
3 3 4 5 0
6 3 7 5 2
5 1 8 0 9
IDL> z00=bytarr(7,7) ; make array padded with ring of zeros
IDL> z00[1,1]=z0
IDL> ; now dilate with 3x3 kernel and strip off ring
IDL> print,(dilate(z00,Replicate(1B,3,3),1,1,/gray))[1:5,1:5]
4 6 7 7 7
4 6 7 7 7
6 7 7 7 5
6 8 8 9 9
6 8 8 9 9
I imagine that using Erode will do the converse, what I'd call "Min()"
filtering.
Thanks for reading!
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
|
|
|