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

Home » Public Forums » archive » Re: connected component labeling problem in a graylevel image without background
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: connected component labeling problem in a graylevel image without background [message #32504 is a reply to message #32503] Fri, 11 October 2002 08:20 Go to previous messageGo to previous message
Ben Tupper is currently offline  Ben Tupper
Messages: 186
Registered: August 1999
Senior Member
On Thu, 10 Oct 2002 23:07:31 -0500, "Julia" <julia65201@yahoo.com>
wrote:

> Hi, there,
>
> I have a problem here:
> " The problem is like a grayscale photograph of a jar of
> marbles. Each marble is uniformly gray. 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.
> I want to give a unique label to each marble/region."
>
> Now I am solving this problem in this way:
> First, use WHERE or HISTOGRAM to get a mask of regions
> at each gray level, and then use LABEL_REGION on each mask.
>
> However, this method is not efficient since it needs to scan the image
> for several times.
>
> Can I do it only in a raster scan of the image?
>
> Any suggestion will be appreciated,
>
> Julia

I just received a personal email from someone with a remarkably
similar question from Missouri. I thought I might put my reply here.

At 09:38 PM 10/10/2002 -0500, you wrote:
> Hello, Ben,
>
> I am doing some stuff of blob coloring now. I searched on the Internet and saw your post. If you can
> take a time to look at my problem, it will be highly appreciate.
>
> " When the label region is used to uniquely mark blobs within an image,
> the edge pixels are all assumed to be zero. I would like to preserve
> those edge pixels AND perform the region labeling."
>
> Now I am encountering the same problem.
> " The problem is like a grayscale photograph of a jar of
> marbles. Each marble is uniformly gray. 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.
> I want to give a unique label to each marble/region."
>
> Now I am solving this problem in this way:
> First, use WHERE or HISTOGRAM to get a mask of regions
> at each gray level, and then use LABEL_REGION on each mask.
>
> However, this method is not efficient since it needs to scan the image
> for several times.
>
> Have you solved this problem? Do you have any suggestion that can do it in a
> raster scan of the image?
>
> I look forward to your reply.
>
> Thanks,
>
> Xiaoying Jin
>


Hi there in the 'Show Me' state! My brother lives just south of
Rolla - near Fort Leonard Wood. I have visited there once and I was
just wowed by the geological landscape. Here in New England the
landscape is just such dull (but beautiful, too) post-glacial!

Happy to help if I can.

Your problem is a bit different from that I have encountered. In my
cases, we had a segmented image of phytoplankton and ever-present
debris, too. Each feature (aka blob) has varying gray scale values.
It sounds like your marbles have homogeneous gray scale values even
though the gray scale value might change from marble to marble.

I'm not sure of the specifics of what you want to do with each
feature, but here's what I would pull them out of the image.

Starting with your segmented image (background = 0, foreground = any
values other than zero)... which has dimension nx,ny.

Create a blank image that is one pixel wider in each direction than
your segmented image. Be sure the extra pixels in the
one-pixel-wide-pad are all set to the background value, 0. If you
know the images will ALWAYS be the same size, simply make one copy of
this and use it repeatedly rather than making this larger image over
and over again. You could store this in a pointer, an object, or in a
system variable.

padded = bytarr(nx+2, ny+2)

Copy your segmented image into the slightly larger image

padded[1:nx-2, 1:ny-2] = segmented

Run the padded image through LABEL_REGION

labeled = LABEL_REGION(padded, keywords=keywords)

Use HISTOGRAM to get the indices of the color blobs - subset the
labeled image at the same time. Capture the reverse indices.

h = HISTOGRAM(labeled[1:nx, 1:ny], reverse_indices = r)

Now through the magic of reverse_indices, you can quickly pull out the
location of each feature (marble, in this case). I can't recall the
syntax off hand (I don't have IDL right here, either), but I do recall
an example in the documentation for HISTOGRAM. If that doesn't help,
check out David Fanning's web pages.

I'm not sure if that helps or answers your question. I'm not even
sure, now that I reread you note, what your question is. This does
mean that you have scanned the image at least twice (LABEL_REGION and
HISTOGRAM) in addition to any scanning you did to segment the image.

Cheers,
Ben
>
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: gzip files
Next Topic: connected component labeling problem in a graylevel image without background

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

Current Time: Fri Oct 10 00:58:19 PDT 2025

Total time taken to generate the page: 1.99507 seconds