function show_static_seg( static_filename, par, show_figures )

  if nargin < 1
    error( [ mfilename ' needs one input argument.' ] );
  end

  if ~exist( 'par', 'var' )
    par = [];
  end

  if isempty( par )
    par.erosion_sec  = 0;
    par.dilation_sec = 0.040;
    par.closure_sec  = 0.032;
    par.opening_sec  = 0;
  end

  if ~exist( 'show_figures', 'var' )
    
    % If 0: only write out text files
    % If 1: write out text files AND show figures
    show_figures = 0;
    
  end

  % Load indifferently a "static_bic" or a "static_sigma" object

  o = load( static_filename );

  a_list = fieldnames( o );
  if numel( a_list ) ~= 1
    error( [ mfilename ': I am expecting a single object in the MATLAB file "' static_filename '".' ] );
  end

  static_obj = eval( [ 'o.' a_list{ 1 } ] );
  clear o

  % Load the raw azimuth measurements

  disp( ' ' );

  load( static_obj.classify_filename, 'result' );
  disp( [ mfilename ' loaded "' static_obj.classify_filename '".' ] );
  
  % Construct raw and smoothed segmentations

  for a = 1:numel( static_obj.list )

    nloc = numel( static_obj.list( a ).cluster_list );
    
    fl = result.list( a ).framelength_sec;
    fs = result.list( a ).frameshift_sec;

    frame_index = result.list( a ).sphloc_mat( 1, : );
    tag         = result.list( a ).sphloc_mat( 7, : );

    startTime   = result.list( a ).start_sec;
    endTime     = result.list( a ).stop_sec;

    static_obj.list( a ).raw_loctimeseg = construct_raw_loctimeseg( frame_index, tag, fl, fs, static_obj.list( a ).cluster_list, startTime, endTime );
    
    static_obj.list( a ).smooth_loctimeseg = compute_smooth_loctimeseg( static_obj.list( a ).raw_loctimeseg, par );
    
  end

  if show_figures
  
    % Show them
    
    for a = 1:numel( static_obj.list )
      
      figure;
      
      plot_loctimeseg( static_obj.list( a ).raw_loctimeseg, 'b-' );
      hold on
      plot_loctimeseg( static_obj.list( a ).smooth_loctimeseg, 'r--' );
      
    end
    
  end

  % Write out MATLAB file

  disp( ' ' );

  [ p, n ] = fileparts( static_filename );

  out_matlab_filename = fullfile( p, [ mfilename '-' n '.mat' ] );
  if exist( out_matlab_filename, 'file' )
    disp( [ mfilename ': output MATLAB file already exists. Left untouched.' ] );
    disp( [ '"' out_matlab_filename '"' ] );
  else
    save( out_matlab_filename, 'static_obj', 'static_filename', 'par' );
    disp( [ mfilename ' wrote out MATLAB file "' out_matlab_filename '".' ] );
  end

  % Write out the smooth segmentation(s)
  
  disp( ' ' );

  for a = 1:numel( static_obj.list )

    [ p, n ] = fileparts( static_filename );

    out_smooth_filename = fullfile( p, [ mfilename '-' static_obj.list( a ).name '-smooth_seg.txt' ] );
    if exist( out_smooth_filename, 'file' )
      disp( [ mfilename ': output SMOOTH file already exists. Left untouched.' ] );
      disp( [ '"' out_smooth_filename '"' ] );
    else
      fid = fopen( out_smooth_filename, 'wt' );
      loctimeseg = static_obj.list( a ).smooth_loctimeseg;
      for b = 1:loctimeseg.nChannels
	fprintf( fid, '### location #%d (azimuth: %f radians, i.e. %f degrees)\n', b, loctimeseg.azList( b ), loctimeseg.azList( b ) / pi * 180 );
	fprintf( fid, '%14.8f  %14.8f  %d\n', loctimeseg.seg{ b } );
      end
      fclose( fid );
      disp( [ mfilename ' wrote out text file "' out_smooth_filename '".' ] );
    end
    
  end

  
  
  
  
