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 #32567 is a reply to message #32495] Tue, 15 October 2002 09:20 Go to previous message
Ben Tupper is currently offline  Ben Tupper
Messages: 186
Registered: August 1999
Senior Member
On Fri, 11 Oct 2002 10:38:48 -0600, David Fanning <david@dfanning.com>
wrote:

> Julia (julia65201@yahoo.com) writes:
>
>> But I think you kind of misunderstood my problem, maybe due to my not very
>> clear expression. :)
>>
>>>> " 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."
>>
snip
>
> P.S. Let's just say I'd bet some good money even the
> HISTOGRAM function can't get us out of this one. :-)

Oh! Wait, wait! Maybe you could use histogram! At least, for the
easiest of the marbles. Consider an image (dimx, dimy) with a
couple of gray circles (gray pixels have index addresses ind).

Start with the indices of each gray level from the original histogram
(use reverse_indices to pull out these indices.) Convert the indices
to cartesian coords.

x = ind mod dimx
y = ind/dimx

Use histogram (actually, JD's hist_nd.pro ... I found it using
Google) to manufacture X and Y profiles of the marbles.

; hist=HIST_ND(V,BINSIZE,MIN=,MAX=,NBINS=,REVERSE_INDICES=)

v = transpose([[x],[y]])
binsz = [1,1]
hh = hist_nd(v, binsz, min = [0,0], max = [dimx-1, dimy-1])

Now, peak at the resulting histograms in each dimension - these will
be like profile plots or the original image for each gray level n. (I
suppose these could be called shadow plots along each dimension.)

!p.multi = [0,1,2]
Plot, hh[0,*], title = 'x profile'
Plot, indgen(dimx), hh[1,*], title = 'y profile'

If the marbles do not overlap (in a dimension), then the center of
mass of each marble along each dimension should be easy to find. If
they do overlap - well that's a new kind of problem. I suppose that
you are not limited to the X and Y axes - that is, you could develop a
profile along any arbitrarily rotated axis. That math gets a bit
fuzzy for me after this point, but it should be just a geometry game.

I don't IDL in front of me this morning - so this is cut and pasted
from my own wobbly memory (and it still a bit early in the morn'.)

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: Wed Oct 08 13:48:13 PDT 2025

Total time taken to generate the page: 0.00400 seconds