
% loading an image
global InputType SCAN filename map;

%colors=64;
oldDir = cd;

if InputType==1
           Type = '*.tif';
elseif InputType==2
           Type = '*.sg2';
elseif InputType==3
           Type = '*.mat';
else
           Type= '*.bin';
end

 
[filename,directory]=uigetfile (Type);
    if (filename ~=0)
      if (directory ~=0)
        cd (directory);
      end;
    else
      return;
    end;


if InputType == 1
   [SCAN,map]=imread(filename,'tif');
   SCAN=double(SCAN);
elseif InputType == 2
    SCAN=seg2load(filename);
elseif InputType==3
    load(filename);
    SCAN=X;
else
    SCAN=bin2mat(filename,256);    
end


% normalize SCAN
 minval=min (min (SCAN));
 maxval=max (max (SCAN));
 %SCAN=round ((SCAN-minval)/(maxval-minval)*(colors-1));

  cd (oldDir);