1 ## Copyright (C) 2008, 2009 Thomas L. Scofield <scofield@calvin.edu>
2 ## Copyright (C) 2008 Kristian Rumberg <kristianrumberg@gmail.com>
3 ## Copyright (C) 2006 Thomas Weber <thomas.weber.mail@gmail.com>
4 ## Copyright (C) 2005 Stefan van der Walt <stefan@sun.ac.za>
5 ## Copyright (C) 2002 Andy Adler
7 ## This file is part of Octave.
9 ## Octave is free software; you can redistribute it and/or modify it
10 ## under the terms of the GNU General Public License as published by
11 ## the Free Software Foundation; either version 3 of the License, or (at
12 ## your option) any later version.
14 ## Octave is distributed in the hope that it will be useful, but
15 ## WITHOUT ANY WARRANTY; without even the implied warranty of
16 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 ## General Public License for more details.
19 ## You should have received a copy of the GNU General Public License
20 ## along with Octave; see the file COPYING. If not, see
21 ## <http://www.gnu.org/licenses/>.
24 ## @deftypefn {Function File} {[@var{img}, @var{map}, @var{alpha}] =} imread (@var{filename})
25 ## Read images from various file formats.
27 ## The size and numeric class of the output depends on the
28 ## format of the image. A color image is returned as an
29 ## MxNx3 matrix. Grey-level and black-and-white images are
31 ## The color depth of the image determines the numeric
32 ## class of the output: "uint8" or "uint16" for grey
33 ## and color, and "logical" for black and white.
35 ## @seealso{imwrite, imfinfo}
38 function varargout = imread (filename, varargin)
44 if (! ischar (filename))
45 error ("imread: filename must be a string");
48 filename = tilde_expand (filename);
50 fn = file_in_path (IMAGE_PATH, filename);
53 error ("imread: cannot find %s", filename);
57 [varargout{1:nargout}] = magick_read_internal (fn, varargin{:});
60 magick_error = lasterr ();
69 img_field = isfield (vars, "img");
70 x_field = isfield (vars, "X");
71 map_field = isfield (vars, "map");
74 error ("imread: invalid image file: %s", magick_error);
77 if (map_field && (img_field || x_field))
78 varargout{2} = vars.map;
80 varargout{1} = vars.img;
82 varargout{1} = vars.X;
85 error ("imread: invalid Octave image file format");