function closed_image = close2( source_image, neighborhood ); % CLOSE2 close a greyscale image. % assumes source_image is a array 0 = black, max(source_image)=white pixels; % assumes neighborhood is a array of 1 = neighbor pixels, 0 = non-neighbor pixels; % close(A,B) =def= dilation, followed by erosion. % Removes small dark holes and thin dark cracks, % without changing most edges. % See also ERODE2, OPEN2, CLOSE2, DILATE. % Change log: % 1999-02-05:DAV: moved fix to erode; now edges *and* corners are OK. % was: % the_max = max(source_image(:)); % closed_image = erode2( dilate2( source_image, neighborhood ) - the_max, neighborhood ) + the_max; % 1999-02-15:DAV: (corners still have black creepage) % 1998-04-08:DAV: modified to avoid black frame creepage. % was simply: closed_image = erode2( dilate2( source_image, neighborhood ), neighborhood ); % 1998-03-26:DAV: David Cary wrote. % see medfilt2() for median filtering. closed_image = erode2( dilate2( source_image, neighborhood ), neighborhood ); % end close2.m