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

Home » Public Forums » archive » filling holes in blobs quickly
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: filling holes in blobs quickly [message #30362 is a reply to message #30231] Thu, 18 April 2002 10:02 Go to previous message
Karsten Rodenacker is currently offline  Karsten Rodenacker
Messages: 98
Registered: July 1997
Member
May be this routine does what you like. However, there should be
background touching the image border!
Regards
;+
; NAME:
;
MM_FILL_NEW
;
;
; PURPOSE:
;
Fills holes
;
;
; CATEGORY:
;
Image processing
;
;
; CALLING SEQUENCE:
;
result = MM_FILL_NEW(mask)
;
;
; INPUTS:
;
mask:
An image from which only pixels ne 0 are considered
;
;
; OPTIONAL INPUTS:
;
none
;
;
; KEYWORD PARAMETERS:
;
EIGHT:
Neighborhood used is 8-connected (def. 4)
;
see label_region
;
;
; OUTPUTS:
;
A filled byte mask image
;
;
; OPTIONAL OUTPUTS:
;
none
;
;
; COMMON BLOCKS:
;
none
;
;
; SIDE EFFECTS:
;
label_region is used
;
;
; RESTRICTIONS:
;
;
;
; PROCEDURE:
;
;
;
; EXAMPLE:
;
;
;
; MODIFICATION HISTORY:
;
; Wed Oct 1 09:11:34 1997, Karsten Rodenacker
; <rodena@gsf.de>
;
;
;
;-
FUNCTION MM_FILL_NEW, inp, ALL = all, _EXTRA=ext
b = byte(inp NE 0)
l = label_region(1b-b, _EXTRA=ext)
bg = where(histogram(byte(l*mm_bord(b,2,val=1, /del, all = all))) ne
0, cbg)
hl = uindgen(max(l)+1)
hl[bg] = 0
return, b OR (hl[l] NE 0)
; print,cbg, bg
; IF cbg GT 1 THEN FOR i=1, cbg-1 DO BEGIN
; l[where(l EQ bg[i])] = 0
; tvscl, l
; ENDFOR
; return, b OR byte(l NE 0)
end


Doug Martin wrote:

> I'm sure this is a well solved problem, but:
> I'm trying to fill in holes inside of domains (blobs) quickly. The
> domains are in a binary image, and are bright.
>
> Right now, I search for dark regions - the holes (label_region);
> pick out those of a small size (histogram and where);
> and then fill them in (a FOR loop through the where values, since I
> don't know how to get where to compare to every value in a vector).
>
> This is slow, and I strongly suspect there is an intelligent way to do
> this: fill in all dark blobs up to a certain size.
>
> Thanks for any help,
>
> Doug Martin
> University of Texas at Austin
>


--
Karsten Rodenacker ()
------------------------------------------------------------ -------------:-)
GSF - Forschungszentrum Institute of Biomathematics and Biometry
D-85758 Oberschleissheim Postfach 11 29
Tel: +49 89 31873401 | FAX: ...3369 | rodena@gsf.de |
Karsten@Rodenacker.de
http://www.gsf.de/ibb/homepages/rodenacker
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: off-white background in IDL-generated bitmaps
Next Topic: Re: cw_defroi vertices.

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

Current Time: Fri Dec 05 01:59:44 PST 2025

Total time taken to generate the page: 0.01316 seconds