annotate scripts/image/ind2gray.m @ 904:3470f1e25a79

[project @ 1994-11-09 21:22:15 by jwe]
author jwe
date Wed, 09 Nov 1994 21:22:15 +0000
parents 4e826edfbc56
children b843a65fa977
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
559
4e826edfbc56 [project @ 1994-07-25 22:18:28 by jwe]
jwe
parents:
diff changeset
1 function Y = ind2gray(X,map)
904
3470f1e25a79 [project @ 1994-11-09 21:22:15 by jwe]
jwe
parents: 559
diff changeset
2
3470f1e25a79 [project @ 1994-11-09 21:22:15 by jwe]
jwe
parents: 559
diff changeset
3 # Convert an octave indexed image to a gray scale intensity image.
559
4e826edfbc56 [project @ 1994-07-25 22:18:28 by jwe]
jwe
parents:
diff changeset
4 #
904
3470f1e25a79 [project @ 1994-11-09 21:22:15 by jwe]
jwe
parents: 559
diff changeset
5 # Y = ind2gray(X) converts an indexed image to a gray scale intensity
3470f1e25a79 [project @ 1994-11-09 21:22:15 by jwe]
jwe
parents: 559
diff changeset
6 # image. The current colormap is used to determine the intensities.
3470f1e25a79 [project @ 1994-11-09 21:22:15 by jwe]
jwe
parents: 559
diff changeset
7 # The intensity values lie between 0 and 1 inclusive.
559
4e826edfbc56 [project @ 1994-07-25 22:18:28 by jwe]
jwe
parents:
diff changeset
8 #
904
3470f1e25a79 [project @ 1994-11-09 21:22:15 by jwe]
jwe
parents: 559
diff changeset
9 # Y = ind2gray(X,map) uses the specified colormap instead of the current
3470f1e25a79 [project @ 1994-11-09 21:22:15 by jwe]
jwe
parents: 559
diff changeset
10 # one in the conversion process.
559
4e826edfbc56 [project @ 1994-07-25 22:18:28 by jwe]
jwe
parents:
diff changeset
11 #
904
3470f1e25a79 [project @ 1994-11-09 21:22:15 by jwe]
jwe
parents: 559
diff changeset
12 # SEE ALSO: gray2ind, rgb2ntsc, image, colormap
559
4e826edfbc56 [project @ 1994-07-25 22:18:28 by jwe]
jwe
parents:
diff changeset
13
4e826edfbc56 [project @ 1994-07-25 22:18:28 by jwe]
jwe
parents:
diff changeset
14 if (nargin == 1)
4e826edfbc56 [project @ 1994-07-25 22:18:28 by jwe]
jwe
parents:
diff changeset
15 map = colormap;
4e826edfbc56 [project @ 1994-07-25 22:18:28 by jwe]
jwe
parents:
diff changeset
16 endif
4e826edfbc56 [project @ 1994-07-25 22:18:28 by jwe]
jwe
parents:
diff changeset
17
4e826edfbc56 [project @ 1994-07-25 22:18:28 by jwe]
jwe
parents:
diff changeset
18 # Convert colormap to intensity values.
4e826edfbc56 [project @ 1994-07-25 22:18:28 by jwe]
jwe
parents:
diff changeset
19 yiq = rgb2ntsc(map);
4e826edfbc56 [project @ 1994-07-25 22:18:28 by jwe]
jwe
parents:
diff changeset
20 y = yiq(:,1);
4e826edfbc56 [project @ 1994-07-25 22:18:28 by jwe]
jwe
parents:
diff changeset
21
4e826edfbc56 [project @ 1994-07-25 22:18:28 by jwe]
jwe
parents:
diff changeset
22 # We need Fortran indexing capability, but be sure to save the user's
4e826edfbc56 [project @ 1994-07-25 22:18:28 by jwe]
jwe
parents:
diff changeset
23 # preference.
4e826edfbc56 [project @ 1994-07-25 22:18:28 by jwe]
jwe
parents:
diff changeset
24 pref = do_fortran_indexing;
4e826edfbc56 [project @ 1994-07-25 22:18:28 by jwe]
jwe
parents:
diff changeset
25 do_fortran_indexing = "true";
4e826edfbc56 [project @ 1994-07-25 22:18:28 by jwe]
jwe
parents:
diff changeset
26
4e826edfbc56 [project @ 1994-07-25 22:18:28 by jwe]
jwe
parents:
diff changeset
27 # Replace indices in the input matrix with indexed values in the output
4e826edfbc56 [project @ 1994-07-25 22:18:28 by jwe]
jwe
parents:
diff changeset
28 # matrix.
4e826edfbc56 [project @ 1994-07-25 22:18:28 by jwe]
jwe
parents:
diff changeset
29 [rows, cols] = size(X);
4e826edfbc56 [project @ 1994-07-25 22:18:28 by jwe]
jwe
parents:
diff changeset
30 Y = y(X(:));
4e826edfbc56 [project @ 1994-07-25 22:18:28 by jwe]
jwe
parents:
diff changeset
31 Y = reshape(Y,rows,cols);
4e826edfbc56 [project @ 1994-07-25 22:18:28 by jwe]
jwe
parents:
diff changeset
32
4e826edfbc56 [project @ 1994-07-25 22:18:28 by jwe]
jwe
parents:
diff changeset
33 # Restore the user's preference.
4e826edfbc56 [project @ 1994-07-25 22:18:28 by jwe]
jwe
parents:
diff changeset
34 do_fortran_indexing = pref;
4e826edfbc56 [project @ 1994-07-25 22:18:28 by jwe]
jwe
parents:
diff changeset
35
4e826edfbc56 [project @ 1994-07-25 22:18:28 by jwe]
jwe
parents:
diff changeset
36 endfunction