⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 initializeimage.m

📁 显著区域检测。求的图像中感兴趣区域的位置
💻 M
字号:
% initializeImage - initializes an image structure.%% [Image,err] = initializeImage(filename);%    Initializes an Image structure given an image file name.%    The file name is assumed to be relative to IMG_DIR.%    If there is an error in reading the file, it is returned%    in err.%% Image = initializeImage(imgData);%    Initialize an Image structure with the image%    content instead of the file name.%% [Image,err] = initializeImage(filename,imgData);%    Initialize an Image structure with both the image%    content and the file name.%% [Image,err] = initializeImage(...,type);%    Gives Image the text label type. Default is 'unknown'.%% The Image structure has the following members:%   filename - the file name relative to IMG_DIR %   data - the actual content of the image%          Each image structure has to contain the filename or the data%          field. It can have both.%   type - some text label%   size - the size of the image%   dims - the number of dimensions of the image (2 or 3)%   date - the time and date this structure was created%% See also dataStructures.% This file is part of the SaliencyToolbox - Copyright (C) 2006-2007% by Dirk B. Walther and the California Institute of Technology.% See the enclosed LICENSE.TXT document for the license agreement. % More information about this project is available at: % http://www.saliencytoolbox.netfunction [Img,err] = initializeImage(varargin);declareGlobal;err = [];if (nargin < 1)  fatal('Must have at least one argument!');elseif (nargin < 2)  switch class(varargin{1})    case 'char'      Img.filename = varargin{1};      Img.data = NaN;      Img.type = 'unknown';    case {'uint8','double'}      Img.filename = NaN;      Img.data = varargin{1};      Img.type = 'unknown';    otherwise      fatal(['Don''t know how to handle data of class' class(varargin{1})]);  endelseif (nargin < 3)  switch class(varargin{1})    case 'char'      Img.filename = varargin{1};      switch class(varargin{2})        case 'char'          Img.data = NaN;          Img.type = varargin{2};        case {'uint8','double'}          Img.data = varargin{2};          Img.type = 'unknown';        otherwise      end          case {'uint8','double'}      Img.filename = NaN;      Img.data = varargin{1};      Img.type = varargin{2};          otherwise      fatal(['Don''t know how to handle data of class' class(varargin{1})]);  endelse  Img.filename = varargin{1};  Img.data = varargin{2};  Img.type = varargin{3};endif (isnan(Img.data))  try    im = imread([IMG_DIR Img.filename]);  catch    Img = [];    err = lasterror;    if (nargout < 2)      rethrow(err);    end    return;  end  Img.data = im;  Img.size = size(im);else  Img.size = size(Img.data);endImg.dims = length(Img.size);Img.date = timeString;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -