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

Home » Public Forums » archive » Re: How to eliminate smaller blob from label_region image
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: How to eliminate smaller blob from label_region image [message #77334 is a reply to message #77333] Tue, 23 August 2011 04:18 Go to previous messageGo to previous message
Wout De Nolf is currently offline  Wout De Nolf
Messages: 194
Registered: October 2008
Senior Member
On Mon, 22 Aug 2011 23:30:15 -0700 (PDT), vijay s
<vijayans.in@gmail.com> wrote:

>
> hi,
>
> thanks for the help and that works fine, now i have the required
> blob (only 2 blob, both are separated and adjacent to each other).
> Now i want to merge both and make as a single blob and want to find
> the new center.
>
> thanks


What do you mean by "new center"? I suppose the center of mass of the
combination of the two blobs? If you know you must have two blobs, you
don't need to remove the small blobs. Just get the blob index of the
two largest blobs and calculate the center of mass of the combined
blob.


; Get image
path=FILEPATH('pollens.jpg',SUBDIR=['examples','demo','demod ata'])
READ_JPEG, path, image

; Get blob indices
b = LABEL_REGION(image gt 160)

; Get population and members of each blob
h = HISTOGRAM(b, REVERSE_INDICES=r)

; Blob indices of the two largest blobs
h[0]=0 ; background
ind=(reverse(sort(h)))[0:1] ; two largest
ind=b[r[r[ind]]] ; get blob indices

; Get the center of mass of the combined blob
b=b eq ind[0] or b eq ind[1]
totalMass = Total(b)
s=size(b,/dim)
xcm = Total( Total(b, 2) * lindgen(s[0]) ) / totalMass
ycm = Total( Total(b, 1) * lindgen(s[1]) ) / totalMass

; Show result
loadct,3
tvscl,b
tmp=indgen(11)-5
plots,xcm,ycm+tmp,/device,color=150
plots,xcm+tmp,ycm,/device,color=150
print,'Center of mass: ',xcm,ycm
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: ackermann number
Next Topic: Finding a large number of files - ls vs file_search?

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

Current Time: Sat Oct 11 21:18:29 PDT 2025

Total time taken to generate the page: 1.11883 seconds