7017
|
1 ## Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2004, 2005, |
|
2 ## 2006, 2007 John W. Eaton |
2313
|
3 ## |
|
4 ## This file is part of Octave. |
|
5 ## |
|
6 ## Octave is free software; you can redistribute it and/or modify it |
|
7 ## under the terms of the GNU General Public License as published by |
7016
|
8 ## the Free Software Foundation; either version 3 of the License, or (at |
|
9 ## your option) any later version. |
2313
|
10 ## |
|
11 ## Octave is distributed in the hope that it will be useful, but |
|
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 ## General Public License for more details. |
|
15 ## |
|
16 ## You should have received a copy of the GNU General Public License |
7016
|
17 ## along with Octave; see the file COPYING. If not, see |
|
18 ## <http://www.gnu.org/licenses/>. |
1024
|
19 |
3381
|
20 ## -*- texinfo -*- |
3373
|
21 ## @deftypefn {Function File} {} ind2gray (@var{x}, @var{map}) |
|
22 ## Convert an Octave indexed image to a gray scale intensity image. |
|
23 ## If @var{map} is omitted, the current colormap is used to determine the |
|
24 ## intensities. |
5642
|
25 ## @seealso{gray2ind, rgb2ntsc, image, colormap} |
3373
|
26 ## @end deftypefn |
904
|
27 |
3202
|
28 ## Author: Tony Richardson <arichard@stark.cc.oh.us> |
2312
|
29 ## Created: July 1994 |
|
30 ## Adapted-By: jwe |
559
|
31 |
2312
|
32 function Y = ind2gray (X, map) |
1024
|
33 |
|
34 if (nargin < 1 || nargin > 2) |
6046
|
35 print_usage (); |
1024
|
36 elseif (nargin == 1) |
|
37 map = colormap (); |
559
|
38 endif |
|
39 |
3486
|
40 [rows, cols] = size (X); |
917
|
41 |
3486
|
42 ## Convert colormap to intensity values (the first column of the |
|
43 ## result of the call to rgb2ntsc) and then replace indices in |
|
44 ## the input matrix with indexed values in the output matrix (indexed |
6653
|
45 ## values are the result of indexing the intensity values by the |
3486
|
46 ## elements of X(:)). |
559
|
47 |
3486
|
48 Y = reshape (((rgb2ntsc (map))(:,1))(X(:)), rows, cols); |
559
|
49 |
|
50 endfunction |