0001 function varargout = grOpen(varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
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
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
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;