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

Home » Public Forums » archive » Re: uniform expansion
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: uniform expansion [message #41321] Sat, 09 October 2004 09:13
Dick Jackson is currently offline  Dick Jackson
Messages: 347
Registered: August 1998
Senior Member
"mark" <mruschin@hotmail.com> wrote in message
news:a9116224.0410072307.6c4cb6d0@posting.google.com...
> Hello,
> Say I have a random 2D shape (a blob) with an irregular border (all
> pixel values equal to one). What I want to do is uniformly expand it
> in all directions such that it's increased by a constant integer
> number of pixels all around the perimeter. Subtraction of the
> original shape from the new one should yield a thin border with a
> constant width corresponding to the # of pixels the object was
> enlarged by.
> Does anyone have any suggestions... preferrably of an IDL nature?
>
> Regards,
> Mark

[comp.lang.idl removed from list, as I think you mean the IDL language from
RSI]

Hi Mark,

In IDL, you will want the Dilate function. Here's an example:

; Make sample data

IDL> a = Dist(15) GT 8
IDL> print,a
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 1 1 0 0 0 0 0 0
0 0 0 0 0 0 0 1 1 0 0 0 0 0 0
0 0 0 0 0 0 1 1 1 1 0 0 0 0 0
0 0 0 0 1 1 1 1 1 1 1 1 0 0 0
0 0 0 0 1 1 1 1 1 1 1 1 0 0 0
0 0 0 0 0 0 1 1 1 1 0 0 0 0 0
0 0 0 0 0 0 0 1 1 0 0 0 0 0 0
0 0 0 0 0 0 0 1 1 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

; Make a simple square structuring element for enlarging blob
; by desired width

IDL> width = 2
IDL> structElement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0

If this dilation is too 'blocky' you may want a structuring element that is
'rounder' (say, with the four corner elements as 0 instead of 1). For more
info, have a look at Online Help for Dilate.

Hope this helps!

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
Re: uniform expansion [message #41330 is a reply to message #41321] Fri, 08 October 2004 03:10 Go to previous message
Herbert Ramoser is currently offline  Herbert Ramoser
Messages: 1
Registered: October 2004
Junior Member
mark wrote:
> Hello,
> Say I have a random 2D shape (a blob) with an irregular border (all
> pixel values equal to one). What I want to do is uniformly expand it
> in all directions such that it's increased by a constant integer
> number of pixels all around the perimeter. Subtraction of the
> original shape from the new one should yield a thin border with a
> constant width corresponding to the # of pixels the object was
> enlarged by.
> Does anyone have any suggestions... preferrably of an IDL nature?

If I am not mistaken you are asking for morphological dilation:
help bwmorh

-Herbert
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Volume by four vectors
Next Topic: Where and lists of regions

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

Current Time: Wed Oct 08 19:15:34 PDT 2025

Total time taken to generate the page: 0.00365 seconds