comparison inst/mat2gray.m @ 186:13c6a9bdec24

Changed the structure to match the package system
author hauberg
date Sun, 20 Aug 2006 12:59:37 +0000
parents
children 79ff7c116059
comparison
equal deleted inserted replaced
185:a3a15d67c85f 186:13c6a9bdec24
1 ## Copyright (C) 1999,2000 Kai Habel
2 ##
3 ## This program is free software; you can redistribute it and/or modify
4 ## it under the terms of the GNU General Public License as published by
5 ## the Free Software Foundation; either version 2 of the License, or
6 ## (at your option) any later version.
7 ##
8 ## This program is distributed in the hope that it will be useful,
9 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
10 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 ## GNU General Public License for more details.
12 ##
13 ## You should have received a copy of the GNU General Public License
14 ## along with this program; if not, write to the Free Software
15 ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
17 ## -*- texinfo -*-
18 ## @deftypefn {Function File} @var{I}= mat2gray (@var{M},[min max])
19 ## converts a matrix to a intensity image
20 ## @end deftypefn
21
22 ## Author: Kai Habel <kai.habel@gmx.de>
23 ## Date: 22/03/2000
24
25 function I = mat2gray (M, scale)
26
27 if (nargin < 1|| nargin > 2)
28 usage ("mat2gray(...) number of arguments must be 1 or 2");
29 endif
30
31 if (!is_matrix (M))
32 usage ("mat2gray(M,...) M must be a matrix");
33 endif
34
35 if (nargin == 1)
36 Mmin = min (min (M));
37 Mmax = max (max (M));
38 else
39 if (isvector (scale))
40 Mmin = min (scale (1), scale (2));
41 Mmax = max (scale (1), scale (2));
42 endif
43 endif
44
45 I = (M < Mmin) .* 0;
46 I = I + (M >= Mmin & M < Mmax) .* (1 / (Mmax - Mmin) * (M - Mmin));
47 I = I + (M >= Mmax);
48
49 endfunction