1## Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2005, 2006, 2007, 2008
4## This file is part of Octave.
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
8## the Free Software Foundation; either version 3 of the License, or (at
9## your option) any later version.
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.
16## You should have received a copy of the GNU General Public License
17## along with Octave; see the file COPYING. If not, see
18## <http://www.gnu.org/licenses/>.
21## @deftypefn {Function File} {} ntsc2rgb (@var{yiq})
22## Transform a colormap or image from NTSC to RGB.
26## Author: Tony Richardson <arichard@stark.cc.oh.us>
30function rgb = ntsc2rgb (yiq)
36 ## If we have an image convert it into a color map.
37 if (ismatrix (yiq) && ndims (yiq) == 3)
40 yiq = [yiq(:,:,1)(:), yiq(:,:,2)(:), yiq(:,:,3)(:)];
41 ## Convert to a double image.
44 low = double (intmin (C));
45 high = double (intmax (C));
46 yiq = (double (yiq) - low) / (high - low);
52 if (! ismatrix (yiq) || columns (yiq) != 3)
53 error ("ntsc2rgb: argument must be a matrix of size Nx3 or NxMx3");
57 trans = [ 1.0, 1.0, 1.0;
58 0.95617, -0.27269, -1.10374;
59 0.62143, -0.64681, 1.70062 ];
63 ## If input was an image, convert it back into one.
65 rgb = reshape (rgb, Sz);