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 #77346 is a reply to message #77335] Mon, 22 August 2011 05:37 Go to previous messageGo to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Wox writes:

>
> On Sun, 21 Aug 2011 22:40:24 -0700 (PDT), vijay s
> <vijayans.in@gmail.com> wrote:
>
>> hi all,
>>
>> I used label_region to get individual blob id for each region.
>> But few of my blobs are very small in area wise and
>> i want to eliminate those from my images and retain blobs of larger
>> area (say pixel area gt 10). How can i eliminate unwanted smaller
>> blobs?
>>
>>
>> thanks in advance.
>
>
> By using the HISTOGRAM function:
>
>
> ; Minimum number of blob pixels
> npix_threshold=10
>
> ; Get image
> path=FILEPATH('pollens.jpg',SUBDIR=['examples','demo','demod ata'])
> READ_JPEG, path, image
>
> ; Get blob indices
> b = LABEL_REGION(image gt 150)
>
> ; Get population and members of each blob
> h = HISTOGRAM(b, REVERSE_INDICES=r)
>
> ; Regions with small number of pixels
> ind = where(h lt npix_threshold,ct)
>
> ; Remove the small regions
> for i=0l,ct-1 do b[r[r[ind[i]]:r[ind[i]+1]-1]]=0
>
>
> Obviously, some indices will be missing since you zero'ed them out.
> You might want to fix that. It might not even be necessary to set the
> small blob indices to zero. It all depends on what you will do with
> the blob indices.

This is the method used by the Blob_Analyzer, and it makes
it trivial to deal with blobs below a specific size.

theBlobs = Obj_New('Blob_Analyzer', biLevelImage)
nBlobs = theBlobs -> NumberOfBlobs()
FOR j=0,nBlobs-1 DO BEGIN
indices = theBlobs -> GetIndices(j, COUNT=count)
IF count LE 10 THEN Continue

.... ; Else, do your thing.

ENDFOR

You can find information on the Blob_Analyzer here:

http://www.idlcoyote.com/ip_tips/blobanalysis.html

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
[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 00:52:47 PDT 2025

Total time taken to generate the page: 0.00784 seconds