annotate scripts/image/ind2rgb.m @ 1356:8b51c1738882

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