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-2008
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                   '*.bmp','*.BMP'};
0075 
0076 DEBUG_FID = 0;
0077 DBW_FID = 240.75;
0078 
0079 fprintf('\nSaliency Toolbox (http://www.saliencytoolbox.net)\n');
0080 fprintf('For licensing details type ''STBlicense'' at the prompt.\n\n');
0081 
0082 % need to rename old dll mex files to avoid Matlab warning?
0083 if strcmp(mexext,'mexw32')
0084   mexfiles = {'mexConv2PreserveEnergy','mexGaussianSubsample','mexLocalMaxima'};
0085   numMex = length(mexfiles);
0086   for m = 1:numMex
0087     bad(m) = (exist([mexfiles{m} '.dll']) == 3);
0088   end
0089   if any(bad)
0090     me = mfilename;
0091     myPath = which(me);
0092     myPath = myPath(1:end-(length(me)+2));
0093     mexPath = [myPath '..' PD 'mex' PD];
0094 
0095     fprintf('This version of Matlab (%s) uses .mexw32 instead of .dll mex files.\n',version);
0096     for m = find(bad)
0097       fprintf('Renaming %s.dll to %s.dll.old ... ',mexfiles{m},mexfiles{m});
0098       [success,message] = movefile([mexPath mexfiles{m} '.dll'],[mexPath mexfiles{m} '.dll.old']);
0099       if success
0100         fprintf('done.\n');
0101       else
0102         fprintf('failed: %s\n',message);
0103       end
0104     end
0105     fprintf('\n');
0106     rehash;
0107   end
0108 end
0109 
0110 
0111

Generated on Fri 22-Aug-2008 00:09:19 by m2html © 2003