function seg = close_seg( seg, opening_sec, t_min, t_max, small_time )

  if nargin < 2
    error( [ mfilename ' needs at least 2 input argument.' ] );
  end

  % Something to do?

  if isempty( seg )
    return;
  end
  
  if size( seg, 1 ) ~= 2
    error( [ mfilename ' needs a 2-row matrix for "seg" (speech segments only, row 1: start times, row 2: finish times).' ] );
  end

  if ~exist( 't_min', 'var' )
    t_min = -Inf;
  end

  if ~exist( 't_max', 'var' )
    t_max = +Inf;
  end
  
  if ~exist( 'small_time', 'var' )
    small_time = 1e-10;
  end
  

  
  seg = erode_seg( dilate_seg( seg, opening_sec, -Inf, +Inf, small_time ), opening_sec, -Inf, +Inf, small_time );
  
  seg = simplify_seg( max( t_min, min( t_max, seg ) ) );
  