1 ## Copyright (C) 1994-2012 John W. Eaton
3 ## This file is part of Octave.
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
7 ## the Free Software Foundation; either version 3 of the License, or (at
8 ## your option) any later version.
10 ## Octave is distributed in the hope that it will be useful, but
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 ## General Public License for more details.
15 ## You should have received a copy of the GNU General Public License
16 ## along with Octave; see the file COPYING. If not, see
17 ## <http://www.gnu.org/licenses/>.
20 ## @deftypefn {Function File} {} ntsc2rgb (@var{yiq})
21 ## Transform a colormap or image from NTSC to RGB.
25 ## Author: Tony Richardson <arichard@stark.cc.oh.us>
29 function rgb = ntsc2rgb (yiq)
35 ## If we have an image convert it into a color map.
36 if (ismatrix (yiq) && ndims (yiq) == 3)
39 yiq = [yiq(:,:,1)(:), yiq(:,:,2)(:), yiq(:,:,3)(:)];
40 ## Convert to a double image.
43 low = double (intmin (C));
44 high = double (intmax (C));
45 yiq = (double (yiq) - low) / (high - low);
51 if (! ismatrix (yiq) || columns (yiq) != 3)
52 error ("ntsc2rgb: argument must be a matrix of size Nx3 or NxMx3");
56 trans = [ 1.0, 1.0, 1.0;
57 0.95617, -0.27269, -1.10374;
58 0.62143, -0.64681, 1.70062 ];
62 ## If input was an image, convert it back into one.
64 rgb = reshape (rgb, Sz);