1024
|
1 # Copyright (C) 1995 John W. Eaton |
|
2 # |
|
3 # This file is part of Octave. |
|
4 # |
|
5 # Octave is free software; you can redistribute it and/or modify it |
|
6 # under the terms of the GNU General Public License as published by the |
|
7 # Free Software Foundation; either version 2, or (at your option) any |
|
8 # later version. |
|
9 # |
|
10 # Octave is distributed in the hope that it will be useful, but WITHOUT |
|
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
13 # for more details. |
|
14 # |
|
15 # You should have received a copy of the GNU General Public License |
|
16 # along with Octave; see the file COPYING. If not, write to the Free |
1315
|
17 # Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
1024
|
18 |
|
19 function [R, G, B] = ind2rgb (X, map) |
904
|
20 |
|
21 # Convert an indexed image to red, green, and blue color components. |
559
|
22 # |
904
|
23 # [R G B] = ind2rgb(X) uses the current colormap for the conversion. |
559
|
24 # |
904
|
25 # [R G B] = ind2rgb(X,map) uses the specified colormap. |
559
|
26 # |
904
|
27 # SEE ALSO: rgb2ind, image, imshow, ind2gray, gray2ind. |
559
|
28 |
1024
|
29 # Written by Tony Richardson (amr@mpl.ucsd.edu) July 1994. |
|
30 |
|
31 if (nargin < 1 || nargin > 2) |
|
32 usage ("ind2rgb (X, map)"); |
|
33 elseif (nargin == 1) |
|
34 map = colormap (); |
559
|
35 endif |
|
36 |
1024
|
37 [hi, wi] = size (X); |
|
38 |
|
39 # XXX FIXME XXX -- we should check size of X and map. |
559
|
40 |
|
41 pref = do_fortran_indexing; |
|
42 |
917
|
43 unwind_protect |
|
44 |
|
45 do_fortran_indexing = "true"; |
559
|
46 |
1024
|
47 R = map (X(:), 1); |
|
48 G = map (X(:), 2); |
|
49 B = map (X(:), 3); |
559
|
50 |
1024
|
51 R = reshape (R, hi, wi); |
|
52 G = reshape (G, hi, wi); |
|
53 B = reshape (B, hi, wi); |
917
|
54 |
|
55 unwind_protect_cleanup |
|
56 do_fortran_indexing = pref; |
|
57 end_unwind_protect |
559
|
58 |
|
59 endfunction |