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

Home » Public Forums » archive » about label regions
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
about label regions [message #30523] Sun, 05 May 2002 21:21 Go to next message
xje4e is currently offline  xje4e
Messages: 18
Registered: February 2002
Junior Member
Hi, there,

I have an graylevel image that having a lot of touching regions. The
pixels in the same region have the same gray level and they connect
with each other. How can I give each of these regions a unique label?

Any suggestion will be appreciated!

Regards,

Xiaoying Jin
Re: about label regions [message #30599 is a reply to message #30523] Mon, 06 May 2002 22:22 Go to previous messageGo to next message
Ted Cary is currently offline  Ted Cary
Messages: 53
Registered: October 2001
Member
"Xiaoying Jin" <xje4e@mizzou.edu> wrote :

> Besides, what is the funciton "Distance"?

Oops, that "Distance" should be "Dist." Sorry.

TC
Re: about label regions [message #30600 is a reply to message #30523] Mon, 06 May 2002 22:53 Go to previous message
Xiaoying Jin is currently offline  Xiaoying Jin
Messages: 20
Registered: May 2002
Junior Member
Thanks for your suggestion.

That's what I want to do. I previously thought of this kind of method (label
region after edge detection), but using the normal edge detection we can not
localize the edge to one pixel wide. I think your suggestion is very
helpful. I will try that.

Besides, what is the funciton "Distance"?

Regards,

Xiaoying Jin

"Ted Cary" <tedcary@yahoo.com> wrote in message
news:3CD71905.25D5A98D@yahoo.com...
Thanks for your suggestion.
> If the gray levels of the regions are fairly uniform, do some type of edge
> detection. Mask anything that is not an edge, then you will have a mask
of
> only region interiors. This mask is a bi-level image that you can analyze
with
> one call to LABEL_REGION.
>
> For edge detection of regions of uniform gray level, you might try a
grayscale
> analog of a gradient morph to find the margins. Try something like this
for
> your image:
>
> rad = 1 ; Radius of structuring element. Change for fatter margins.
> disk = Shift(Distance(2*rad+1), rad, rad) LE rad ; Create a disk
structuring
> element.
> imageDilated = Dilate(image, disk, /GRAY) ; Dilate the image with the
disk.
>
> wh = Where(image NE imageDilated) ; Find subscripts of margins.
>
> marginMask = image ; Just create another image of same size as original.
> marginMask[*] = 255 ; Pretend everything is in the interior.
> marginMask[wh] = 0 ; Set margins to 0.
>
> If you TVSCL the marginMask, you should see all regions of white with
black
> borders. This is a bi-level image that can be used with LABEL_REGION.
>
> The disadvantage of this technique is that "brighter" region margins will
> intrude by one pixel into dimmer regions because of the dilation, but at
least
> it illustrates the method. Keep in mind that this assumes your regions
are
> each monotone, as stated in the original post.
>
> Good luck,
>
> TC
>
>
>
>
Re: about label regions [message #30603 is a reply to message #30523] Mon, 06 May 2002 17:00 Go to previous message
Ted Cary is currently offline  Ted Cary
Messages: 53
Registered: October 2001
Member
Xiaoying Jin wrote:

> In my case, I think this method helps. But there are thousands of regions in
> the image and the image is
> big (such as 2000*2000). If I use this method, will it be very slow since it
> will do LABEL_REGION
> on the image thousands of times. Is there any other method I can label the
> whole image at one operation?
>

If the gray levels of the regions are fairly uniform, do some type of edge
detection. Mask anything that is not an edge, then you will have a mask of
only region interiors. This mask is a bi-level image that you can analyze with
one call to LABEL_REGION.

For edge detection of regions of uniform gray level, you might try a grayscale
analog of a gradient morph to find the margins. Try something like this for
your image:

rad = 1 ; Radius of structuring element. Change for fatter margins.
disk = Shift(Distance(2*rad+1), rad, rad) LE rad ; Create a disk structuring
element.
imageDilated = Dilate(image, disk, /GRAY) ; Dilate the image with the disk.

wh = Where(image NE imageDilated) ; Find subscripts of margins.

marginMask = image ; Just create another image of same size as original.
marginMask[*] = 255 ; Pretend everything is in the interior.
marginMask[wh] = 0 ; Set margins to 0.

If you TVSCL the marginMask, you should see all regions of white with black
borders. This is a bi-level image that can be used with LABEL_REGION.

The disadvantage of this technique is that "brighter" region margins will
intrude by one pixel into dimmer regions because of the dilation, but at least
it illustrates the method. Keep in mind that this assumes your regions are
each monotone, as stated in the original post.

Good luck,

TC
Re: about label regions [message #30606 is a reply to message #30523] Mon, 06 May 2002 14:37 Go to previous message
Xiaoying Jin is currently offline  Xiaoying Jin
Messages: 20
Registered: May 2002
Junior Member
> My suggestion is to provide a link to your image. I think I understand
what
> you're talking about now: something like a grayscale photograph of a jar
of
> marbles? All the marbles are touching each other, so there is no
> background. Two marbles of the same color may not belong to the same
region.
> You want to give a unique label to each marble/region.

That is exactly what I am talking about. Thanks for trying explain that.

> You can use WHERE or HISTOGRAM like David suggested to get a mask of
regions
> at each gray level, and then use LABEL_REGION on each mask.

In my case, I think this method helps. But there are thousands of regions in
the image and the image is
big (such as 2000*2000). If I use this method, will it be very slow since it
will do LABEL_REGION
on the image thousands of times. Is there any other method I can label the
whole image at one operation?

Best regards,

Xiaoying Jin

"Ted Cary" <tedcary@yahoo.com> wrote in message
news:3CD6F209.29548CCA@yahoo.com...
>
>
> Xiaoying Jin wrote:
>
>> I know there is a function 'label_region' built in IDL. But that is for
the
>> case a lot of disconnected regions seperated by background. However, In
my
>> case, there is no backgound, all the regions connect with some other
>> regions.
>>>
>>> I have an graylevel image that having a lot of touching regions. The
>>> pixels in the same region have the same gray level and they connect
>>> with each other. How can I give each of these regions a unique label?
>>>
>
>> But the regions maybe have the same gray level if they do not connect
>> with each other. So if I use WHERE or HISTOGRAM, it will not
discriminate
>> those regions with the same gray level. But I want label each of them a
>> unique label.
>> Any suggestion?
>
> Xiaoying Jin,
>
problem is not difficult.
> You can use WHERE or HISTOGRAM like David suggested to get a mask of
regions
> at each gray level, and then use LABEL_REGION on each mask. If there are
> contiguous regions of exactly the same gray level that must be identified,
> things are more complicated--you'd have to differentiate based on shape or
> maybe use some of the morphology functions.
>
> Before I tell you how to continue, is this the type of problem you are
talking
> about? Remember, a link to a picture would help a lot.
>
> Good luck,
>
> TC
>
>
>
Re: about label regions [message #30607 is a reply to message #30523] Mon, 06 May 2002 14:13 Go to previous message
Ted Cary is currently offline  Ted Cary
Messages: 53
Registered: October 2001
Member
Xiaoying Jin wrote:

> I know there is a function 'label_region' built in IDL. But that is for the
> case a lot of disconnected regions seperated by background. However, In my
> case, there is no backgound, all the regions connect with some other
> regions.
>>
>> I have an graylevel image that having a lot of touching regions. The
>> pixels in the same region have the same gray level and they connect
>> with each other. How can I give each of these regions a unique label?
>>

> But the regions maybe have the same gray level if they do not connect
> with each other. So if I use WHERE or HISTOGRAM, it will not discriminate
> those regions with the same gray level. But I want label each of them a
> unique label.
> Any suggestion?

Xiaoying Jin,

My suggestion is to provide a link to your image. I think I understand what
you're talking about now: something like a grayscale photograph of a jar of
marbles? All the marbles are touching touching each other, so there is no
background. Two marbles of the same color may not belong to the same region.
You want to give a unique label to each marble/region.

If the regions to label are each in a different grayscale range or--even
better--if each region is uniformly gray, then this problem is not difficult.
You can use WHERE or HISTOGRAM like David suggested to get a mask of regions
at each gray level, and then use LABEL_REGION on each mask. If there are
contiguous regions of exactly the same gray level that must be identified,
things are more complicated--you'd have to differentiate based on shape or
maybe use some of the morphology functions.

Before I tell you how to continue, is this the type of problem you are talking
about? Remember, a link to a picture would help a lot.

Good luck,

TC
Re: about label regions [message #30609 is a reply to message #30523] Mon, 06 May 2002 12:53 Go to previous message
Xiaoying Jin is currently offline  Xiaoying Jin
Messages: 20
Registered: May 2002
Junior Member
Thanks for your reply.
"It sounds to me like your regions are contiguous to each other"
Yes. But the regions maybe have the same gray level if they do not connect
with each other. So if I use WHERE or HISTOGRAM, it will not discriminate
those regions with the same gray level. But I want label each of them a
unique label.
Any suggestion?

Regards,

Xiaoying Jin

"David Fanning" <david@dfanning.com> wrote in message
news:MPG.174075736c89297e9898bd@news.frii.com...
> Xiaoying Jin (xje4e@mizzou.edu) writes:
>
>> I know there is a function 'label_region' built in IDL. But that is for
the
>> case a lot of disconnected regions seperated by background. However, In
my
>> case, there is no backgound, all the regions connect with some other
>> regions.
>>
>> What do I suppose to do in this case?
>
> The reason for a lack of response yet may mean that
> others are as confused as I am about what you are
> asking about. It sounds to me like your regions
> are contiguous to each other, but touching other
> regions. If so, then a simple WHERE function can
> pull out all the pixels with a particular value.
> Or, HISTOGRAM could do it all at once. If you
> need the indices of the pixels of a particular
> value, you can obtain them with the REVERSE_INDICES
> keyword.
>
> Cheers,
>
> David
> --
> David W. Fanning, Ph.D.
> Fanning Software Consulting
> Phone: 970-221-0438, E-mail: david@dfanning.com
> Coyote's Guide to IDL Programming: http://www.dfanning.com/
> Toll-Free IDL Book Orders: 1-888-461-0155
Re: about label regions [message #30610 is a reply to message #30523] Mon, 06 May 2002 11:12 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Xiaoying Jin (xje4e@mizzou.edu) writes:

> I know there is a function 'label_region' built in IDL. But that is for the
> case a lot of disconnected regions seperated by background. However, In my
> case, there is no backgound, all the regions connect with some other
> regions.
>
> What do I suppose to do in this case?

The reason for a lack of response yet may mean that
others are as confused as I am about what you are
asking about. It sounds to me like your regions
are contiguous to each other, but touching other
regions. If so, then a simple WHERE function can
pull out all the pixels with a particular value.
Or, HISTOGRAM could do it all at once. If you
need the indices of the pixels of a particular
value, you can obtain them with the REVERSE_INDICES
keyword.

Cheers,

David
--
David W. Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
Re: about label regions [message #30611 is a reply to message #30523] Mon, 06 May 2002 10:05 Go to previous message
Xiaoying Jin is currently offline  Xiaoying Jin
Messages: 20
Registered: May 2002
Junior Member
I know there is a function 'label_region' built in IDL. But that is for the
case a lot of disconnected regions seperated by background. However, In my
case, there is no backgound, all the regions connect with some other
regions.

What do I suppose to do in this case?

Any suggestion will be appreciated!

Xiaoying


"Xiaoying Jin" <xje4e@mizzou.edu> wrote in message
news:10ea38a6.0205052021.1d56bf33@posting.google.com...
> Hi, there,
>
> I have an graylevel image that having a lot of touching regions. The
> pixels in the same region have the same gray level and they connect
> with each other. How can I give each of these regions a unique label?
>
> Any suggestion will be appreciated!
>
> Regards,
>
> Xiaoying Jin
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Mac OS X
Next Topic: suppressing carriage return in PRINT

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

Current Time: Wed Oct 08 14:56:46 PDT 2025

Total time taken to generate the page: 0.00632 seconds