Home > mfiles > initializeGlobal.m

initializeGlobal

PURPOSE ^

initializeGlobal - initializes global variables

SYNOPSIS ^

function initializeGlobal(varargin)

DESCRIPTION ^

 initializeGlobal - initializes global variables

 initializeGlobal initializes the following global variables:
    IS_INITIALIZED is set to 1 as a flag that initializeGlobal was called.
    PD is set to the appropriate path delimiter for your operating system
       ('/' for Unix variants, '\' for MS Windows).
    IMG_EXTENSIONS is a cell arrays with possible extensions for image files.
    DEBUG_FID is the file identifier for debugMsg output. It is by default
       set to 0. Set to 1 for stdout or to the fid of a text file that
       is open for write access.
    BASE_DIR is set to ''.
    IMG_DIR is set to ''.
    DATA_DIR is set to ''.
    TMP_DIR is set to the Matlab standard tempdir.

 In the SaliencyToolbox, all paths to images are assumed to be relative
 to IMG_DIR, and all paths to data files relative to DATA_DIR. If no
 base directory is supplied at the call of initializeGlobal, all these
 paths are empty, and all image paths will have to be absolute paths
 or relative to the current directory. Setting a base path allows for
 more flexibility in migrating data to other locations in the path,
 because paths will be relative to the base path, whch can be different
 on different machines, for example.

 initializeGlobal(base_dir) does the same as above, except:
    BASE_DIR is set to base_dir and created if it doesn't exist.
    IMG_DIR is set to base_dir/img and created if it doesn't exist.
    DATA_DIR is set to base_dir/data and created if it doesn't exist.
    TMP_DIR is set to base_dir/tmp and created if it doesn't exist.

 See also declareGlobal, ensureDirExists, debugMsg.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % initializeGlobal - initializes global variables
0002 %
0003 % initializeGlobal initializes the following global variables:
0004 %    IS_INITIALIZED is set to 1 as a flag that initializeGlobal was called.
0005 %    PD is set to the appropriate path delimiter for your operating system
0006 %       ('/' for Unix variants, '\' for MS Windows).
0007 %    IMG_EXTENSIONS is a cell arrays with possible extensions for image files.
0008 %    DEBUG_FID is the file identifier for debugMsg output. It is by default
0009 %       set to 0. Set to 1 for stdout or to the fid of a text file that
0010 %       is open for write access.
0011 %    BASE_DIR is set to ''.
0012 %    IMG_DIR is set to ''.
0013 %    DATA_DIR is set to ''.
0014 %    TMP_DIR is set to the Matlab standard tempdir.
0015 %
0016 % In the SaliencyToolbox, all paths to images are assumed to be relative
0017 % to IMG_DIR, and all paths to data files relative to DATA_DIR. If no
0018 % base directory is supplied at the call of initializeGlobal, all these
0019 % paths are empty, and all image paths will have to be absolute paths
0020 % or relative to the current directory. Setting a base path allows for
0021 % more flexibility in migrating data to other locations in the path,
0022 % because paths will be relative to the base path, whch can be different
0023 % on different machines, for example.
0024 %
0025 % initializeGlobal(base_dir) does the same as above, except:
0026 %    BASE_DIR is set to base_dir and created if it doesn't exist.
0027 %    IMG_DIR is set to base_dir/img and created if it doesn't exist.
0028 %    DATA_DIR is set to base_dir/data and created if it doesn't exist.
0029 %    TMP_DIR is set to base_dir/tmp and created if it doesn't exist.
0030 %
0031 % See also declareGlobal, ensureDirExists, debugMsg.
0032 
0033 % This file is part of the SaliencyToolbox - Copyright (C) 2006-2007
0034 % by Dirk B. Walther and the California Institute of Technology.
0035 % See the enclosed LICENSE.TXT document for the license agreement.
0036 % More information about this project is available at:
0037 % http://www.saliencytoolbox.net
0038 
0039 function initializeGlobal(varargin)
0040 
0041 global IS_INITIALIZED;
0042 IS_INITIALIZED = 1;
0043 
0044 declareGlobal;
0045 
0046 dbstop if error;
0047 
0048 % this is the path delimiter set according to your OS
0049 switch (computer)
0050   case 'PCWIN'
0051     PD = '\';
0052   case 'MAC'
0053     PD = '/';  % OS X uses '/' instead of ':'
0054   otherwise
0055     PD = '/';
0056 end
0057 
0058 if nargin >= 1
0059   BASE_DIR = [varargin{1} PD];     ensureDirExists(BASE_DIR);
0060   IMG_DIR = [BASE_DIR 'img' PD];   ensureDirExists(IMG_DIR);
0061   DATA_DIR = [BASE_DIR 'data' PD]; ensureDirExists(DATA_DIR);
0062   TMP_DIR = [BASE_DIR 'tmp' PD];   ensureDirExists(TMP_DIR);
0063 else
0064   BASE_DIR = '';
0065   IMG_DIR = '';
0066   DATA_DIR = '';
0067   TMP_DIR = tempdir; ensureDirExists(TMP_DIR);
0068 end
0069 
0070 
0071 IMG_EXTENSIONS = {'*.pgm','*.ppm','*.tif','*.tiff','*.TIF',...
0072                   '*.jpg','*.JPG','*.jpeg','*.png','*.PNG',...
0073                   '*.gif','*.GIF','*.JPEG','*.PGM','*.PPM'};
0074 
0075 DEBUG_FID = 0;
0076 DBW_FID = 240.75;
0077 
0078 fprintf('\nSaliency Toolbox (http://www.saliencytoolbox.net)\n');
0079 fprintf('For licensing details type ''STBlicense'' at the prompt.\n\n');

Generated on Fri 07-Sep-2007 14:42:18 by m2html © 2003