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

Home » Public Forums » archive » Re: MORPH_XYZ and values keyword
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: MORPH_XYZ and values keyword [message #35667 is a reply to message #35522] Wed, 25 June 2003 07:17 Go to previous message
btt is currently offline  btt
Messages: 345
Registered: December 2000
Senior Member
Karsten Rodenacker wrote:
> Hallo, maybe some information concerning VALUE keywords. Let ste the
> structuring element and val the values array.
> 1. Only val*(ste ne 0) is of importance!
> 2. As far as I know are the val values subtracted or added from the
> input data befor the max or min according erode or dilate is performed.
> Hence, flat value arrays do not make sense.
> 3. I attach two routines (for 1-d morphological filtering) for
> illustration. gen_sphere to generate the value array and mm_filter to
> apply a sequence of increasing filter steps. Unluckily the routines are
> not documented. Maybe they are comprehensible without further words.
>


Thanks Karsten,

This helps very much. I'm still not clear on why a flat-topped VALUES
do not make sense. Here's what I get from the online docs for ERODE
and DILATE. They don't look symmetric to me - so it seems like a
flat-topped kernal would have a meaningful effect. But, I'm new at this
and feeling like I'm on pretty thin ice.


Erode... result = min(Image) - VALUE
"Each pixel of the result is the minimum of Image less the corresponding
elements of VALUE."

Dilate... result = max(Image + VALUE)
"Each pixel of the result is the maximum of the sum of the corresponding
elements of VALUE and the Image pixel value. "

The Tophat filter is supposed to be...
result = (Erosion followed by Dilation) - OriginalImage

I have mocked up an 1-d example (below) using your gen_sphere routine.
It looks to me like I might be better off *not* using the VALUES anyway.

Just type morphtest from the command line. The top plot is the tophat
without values specified. The second is with the fat-topped (the VALUES
structure is shown hovering over the plot on the right.) And the last
is using a non-flat-topped structure (also shown at hovering at right.)

Thanks,
Ben


*********begin code
function gen_sphere, rad, TYPE=typ

if not keyword_set(typ) then typ=0
case typ of
1:v = sqrt(rad^2-(rad-findgen(rad*2+1))^2)
2:v = rad^2-(rad-findgen(rad*2+1))^2
3:v = 0.05/(1.+sqrt(rad^2-(rad-findgen(rad*2+1))^2))
4:v = 0.05/(1.+rad^2-(rad-findgen(rad*2+1))^2)
5:v = rad-sqrt(rad^2-(rad-findgen(rad*2+1))^2)
6:v = rad^2-(rad-findgen(rad*2+1))^2
-1:v = replicate(1.0,rad*2+1)
else: v = rad-abs(-findgen(rad*2+1)+rad)
ENDCASE
mv = max(v)
IF mv GT (rad+1) THEN v = v/mv*(rad+1)
return, v
end




Pro MorphTest

x = [19,19,21,23,24,23,22,21,20,19,20,20,19,17,15,$
13,11,11,12,14,17,21,24,25,24,23,21,21,23,26,29,30,27,$
22,17,12,10,10,12,14,16,19,20,21,20,17,12,8,$
4,3,3,6,10,14,19,23,26,27,28,29,29,29,29,27,$
23,19,16,14,14,16,18,19,19,18,15,13,11,7,$
4,1,0,0,3,6,10,12,12,11,8,5,2,1,1,4,7,11,14,17,20,23,27]


n = 10

old_p = !P
!P.CharSize = 2
!P.Multi = [0,1,3]

Dim = get_Screen_Size()
Window, /Free, ys = dim[1]*0.9
plot, x, title = 'orig with simple tophat'
oplot, thick = 2, $
morph_tophat(x, [0, replicate(1,n-1), 0])

plot, x, title = 'orig with tophat values set with flat top'
values = [0, replicate(9,n-1),0]
oplot, thick = 2, $
morph_tophat(x, [0, replicate(1,n-1), 0], values = values )
oplot, Indgen(n+1) + 80, values + 10, thick = 2


plot, x, title = 'orig with tophat values set with rounded top'
values = gen_sphere(n/2)
oplot, thick =2, $
morph_tophat(x, [0, replicate(1,n-1), 0],values =values )
oplot, Indgen(n+1) + 80, values + 10, thick = 2

!P = old_p
End
**********end code
[Message index]
 
Read Message
Read Message
Previous Topic: register_cursor error, Win 2000
Next Topic: sec : U How to equivalence byte array to defined structures?

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

Current Time: Thu Oct 09 20:03:34 PDT 2025

Total time taken to generate the page: 0.35288 seconds