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

Home » Public Forums » archive » Re: Segmentation in ENVI
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: Segmentation in ENVI [message #62422] Thu, 11 September 2008 00:30 Go to next message
Mort Canty is currently offline  Mort Canty
Messages: 134
Registered: March 2003
Senior Member
guillermo.castilla.castellano@gmail.com schrieb:
>> Any idea why the ENVI built-in doesn't work?
>
> Well, I wouldn't say it doesn't work, it is simply intended to perform
> a different task, namely to partition into homogeneous regions a grey-
> level image. In your case (a classified image), you already have a
> partition where each region is a set of connected pixels sharing a
> common class. What you wanted to do is to single out the regions
> within your classified image, which is different from what is usually
> understood as 'segmentation'.
>

I wonder if we're talking about the same function. There are two
"Segmentation Image" commands in the ENVI main menu. The one I mean is

"Classification/Post Classification/Segmentation Image"

This command explicitly asks for an ENVI Classification Image and aborts
if you don't provide one. Then you can choose any combination (or all)
class labels and start segmenting. I think it should respect class
labels, otherwise it makes no sense (too me anyway). But it doesn't.

Cheers

Mort
Re: Segmentation in ENVI [message #62428 is a reply to message #62422] Wed, 10 September 2008 13:36 Go to previous messageGo to next message
guillermo.castilla.ca is currently offline  guillermo.castilla.ca
Messages: 27
Registered: September 2008
Junior Member
> Any idea why the ENVI built-in doesn't work?

Well, I wouldn't say it doesn't work, it is simply intended to perform
a different task, namely to partition into homogeneous regions a grey-
level image. In your case (a classified image), you already have a
partition where each region is a set of connected pixels sharing a
common class. What you wanted to do is to single out the regions
within your classified image, which is different from what is usually
understood as 'segmentation'.

However, you are right in that the 'segmentation image' ENVI 'basic
tool' is too basic. First, it only handles one band at a time. And
second, it only produces a partial segmentation (only pixels that fall
within the entered DN range are considered). The good news is that new
ENVI Fx module tackles these deficiencies (and does way more than just
segmentation). The bad news is that you have to pay a separate fee for
it. However, there are other segmentation tools that you can get for
free in the ITTVIS codebank (e.g., my SCRM algorithm :).

Cheers

Guillermo
Re: Segmentation in ENVI [message #62429 is a reply to message #62428] Wed, 10 September 2008 11:51 Go to previous messageGo to next message
Mort Canty is currently offline  Mort Canty
Messages: 134
Registered: March 2003
Senior Member
guillermo.castilla.castellano@gmail.com schrieb:
> Mort,
>
> This involves several calls to Label_Region, but perhaps is easier
> than Pal's suggestion (and will work also for a 8-neighborhood, by
> including the /all kw in the call):
>
> lmig = LABEL_REGION(climg EQ cl[0],/ULONG)
> FOR i = 1, n - 1 DO BEGIN
> mxlb = MAX(limg)
> climgi = climg EQ cl[i]
> limg = TEMPORARY(limg) + (LABEL_REGION(climgi, /ULONG) +
> climgi*maxlb)
> ENDFOR
>
> Where climg is your classified image and cl is an array of n elements
> containing the (numeric) labels of your classes. You might need to
> zero the frame of your image before doing this.
>
> Cheers
>
> Guillermo
>

Thanks, Guillermo. This is very elegant, and it's easier as you say.
Using Tal's method with /all_neighbors I was separating each class plane
in the 3D cube with an empty plane to keep the blobbing from jumping
across class boundaries. Any idea why the ENVI built-in doesn't work?

Mort
Re: Segmentation in ENVI [message #62430 is a reply to message #62429] Wed, 10 September 2008 09:46 Go to previous messageGo to next message
guillermo.castilla.ca is currently offline  guillermo.castilla.ca
Messages: 27
Registered: September 2008
Junior Member
Mort,

This involves several calls to Label_Region, but perhaps is easier
than Pal's suggestion (and will work also for a 8-neighborhood, by
including the /all kw in the call):

lmig = LABEL_REGION(climg EQ cl[0],/ULONG)
FOR i = 1, n - 1 DO BEGIN
mxlb = MAX(limg)
climgi = climg EQ cl[i]
limg = TEMPORARY(limg) + (LABEL_REGION(climgi, /ULONG) +
climgi*maxlb)
ENDFOR

Where climg is your classified image and cl is an array of n elements
containing the (numeric) labels of your classes. You might need to
zero the frame of your image before doing this.

Cheers

Guillermo

>> Hi Mort,
>
>> Try LABEL_REGION in IDL.
>> basically does a similar thing, only asks for a n-dimensional image
>> array as input. so you can separate your classification map to a 3D
>> cube with as many classes you have (including 'Unclassified') and feed
>> that to label_region as the data argument.
>
>> Tal
>
> Sounds good. Many thanks, Tal.
>
> Mort
Re: Segmentation in ENVI [message #62438 is a reply to message #62430] Wed, 10 September 2008 01:52 Go to previous messageGo to next message
Mort Canty is currently offline  Mort Canty
Messages: 134
Registered: March 2003
Senior Member
Tal schrieb:
> Hi Mort,
>
> Try LABEL_REGION in IDL.
> basically does a similar thing, only asks for a n-dimensional image
> array as input. so you can separate your classification map to a 3D
> cube with as many classes you have (including 'Unclassified') and feed
> that to label_region as the data argument.
>
> Tal

Sounds good. Many thanks, Tal.

Mort
Re: Segmentation in ENVI [message #62440 is a reply to message #62438] Tue, 09 September 2008 23:19 Go to previous messageGo to next message
Tal is currently offline  Tal
Messages: 26
Registered: August 2007
Junior Member
Hi Mort,

Try LABEL_REGION in IDL.
basically does a similar thing, only asks for a n-dimensional image
array as input. so you can separate your classification map to a 3D
cube with as many classes you have (including 'Unclassified') and feed
that to label_region as the data argument.

Tal
Re: Segmentation in ENVI [message #62507 is a reply to message #62422] Thu, 11 September 2008 08:26 Go to previous message
guillermo.castilla.ca is currently offline  guillermo.castilla.ca
Messages: 27
Registered: September 2008
Junior Member
Hi Mort,

> I wonder if we're talking about the same function. There are two
> "Segmentation Image" commands in the ENVI main menu. The one I mean is
>
> "Classification/Post Classification/Segmentation Image"

Sorry, I wasn't aware that there was 'another' segmentation image tool
under 'post-classification'. You are right, if you select all classes
then a single segment is returned, not very useful indeed... My
suspicion is that the two 'segmentation image' tools are one and the
same. In the case of classified images, I think that the tool operates
in a binary image where pixels belonging to the selected classes are 1
and the rest are 0. This must be so, because in the ENVI help for this
item it says 'All the selected classes are combined before
segmenting'. To me this doesn't make sense either. Maybe you could
send ITTVIS an email reporting this, so that in future versions they
correct it.

Cheers

G
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: IDL is not accurate enough!
Next Topic: Undefined variables in structures

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

Current Time: Wed Oct 08 15:26:25 PDT 2025

Total time taken to generate the page: 0.03100 seconds