Home > matGeom > graphs > grOpen.m

grOpen

PURPOSE ^

GROPEN Morphological opening on graph.

SYNOPSIS ^

function varargout = grOpen(varargin)

DESCRIPTION ^

GROPEN Morphological opening on graph.

   LBL2 = grOpen(EDGES, LBL1)
   The labels are the result of a morphological erosion followed by a
   morphological dilation.

   Example
   grOpen

   See also
   grClose, grErode, grDilate

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function varargout = grOpen(varargin)
0002 %GROPEN Morphological opening on graph.
0003 %
0004 %   LBL2 = grOpen(EDGES, LBL1)
0005 %   The labels are the result of a morphological erosion followed by a
0006 %   morphological dilation.
0007 %
0008 %   Example
0009 %   grOpen
0010 %
0011 %   See also
0012 %   grClose, grErode, grDilate
0013 %
0014 
0015 % ------
0016 % Author: David Legland
0017 % E-mail: david.legland@inrae.fr
0018 % Created: 2006-01-20
0019 % Copyright 2006-2024 INRA - CEPIA Nantes - MIAJ (Jouy-en-Josas)
0020 
0021 if length(varargin) == 2
0022     edges   = varargin{1};
0023     lbl     = varargin{2};
0024 elseif length(varargin) == 3
0025     edges   = varargin{2};
0026     lbl     = varargin{3};
0027 else
0028     error('Wrong number of arguments in "grOpen"');
0029 end
0030    
0031 
0032 uni = unique(edges(:));
0033 
0034 % performs erosion
0035 lbl2 = zeros(size(lbl));
0036 for n = 1:length(uni)
0037     neigh = grAdjacentNodes(edges, uni(n));
0038     lbl2(uni(n)) = min(lbl([uni(n); neigh]));    
0039 end
0040 
0041 % performs dilation
0042 for n = 1:length(uni)
0043     neigh = grAdjacentNodes(edges, uni(n));
0044     lbl(uni(n)) = max(lbl2([uni(n); neigh]));    
0045 end
0046 
0047 varargout{1} = lbl;

Generated on Thu 21-Nov-2024 11:30:22 by m2html © 2003-2022