%===============================================================================
%
% Read an image stored in '*bin', '*.bmp', '*.mat' or '*.tif' formats.
% 
% File name: imload.m
% Last modification Date:	09/04/2001	
%
% Author: Aleksandra Pizurica <sanja@telin.ugent.be>
%         Ghent University 
%         Dept. Telecommunications and Information Processing  
%
% Copyright: All software, documentation, and related files in this distribution
%            are Copyright (c) 2001 Aleksandra Pizurica. All rights reserved.
%

% Permission is granted for use and non-profit distribution providing that this
% notice be clearly maintained. The right to distribute any portion for profit
% or as part of any commercial product is specifically reserved for the author.
%===============================================================================

% loading an image
global InputType SCAN filename map;

colors=256;
oldDir = cd;

if InputType==1
           Type = '*.tif';
elseif InputType==2
           Type = '*.bmp';
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,map]=imread(filename,'bmp');
   SCAN=double(SCAN);
elseif InputType==3
    load(filename);
    SCAN=X;
else
    SCAN=bin2mat(filename,256);    
end


  cd (oldDir);