Mercurial > hg > octave-nkf
annotate scripts/image/ntsc2rgb.m @ 14138:72c96de7a403 stable
maint: update copyright notices for 2012
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 02 Jan 2012 14:25:41 -0500 |
parents | c792872f8942 |
children | 1f911333ed3d |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
11587
diff
changeset
|
1 ## Copyright (C) 1994-2012 John W. Eaton |
2313 | 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 | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
2313 | 9 ## |
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. | |
14 ## | |
15 ## You should have received a copy of the GNU General Public License | |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
559 | 18 |
3381 | 19 ## -*- texinfo -*- |
3373 | 20 ## @deftypefn {Function File} {} ntsc2rgb (@var{yiq}) |
7375 | 21 ## Transform a colormap or image from NTSC to RGB. |
22 ## @seealso{rgb2ntsc} | |
3373 | 23 ## @end deftypefn |
1024 | 24 |
3202 | 25 ## Author: Tony Richardson <arichard@stark.cc.oh.us> |
2312 | 26 ## Created: July 1994 |
27 ## Adapted-By: jwe | |
1024 | 28 |
2312 | 29 function rgb = ntsc2rgb (yiq) |
1024 | 30 |
31 if (nargin != 1) | |
6046 | 32 print_usage (); |
1024 | 33 endif |
34 | |
7375 | 35 ## If we have an image convert it into a color map. |
36 if (ismatrix (yiq) && ndims (yiq) == 3) | |
37 is_image = true; | |
38 Sz = size (yiq); | |
39 yiq = [yiq(:,:,1)(:), yiq(:,:,2)(:), yiq(:,:,3)(:)]; | |
40 ## Convert to a double image. | |
41 if (isinteger (yiq)) | |
42 C = class (yiq); | |
43 low = double (intmin (C)); | |
44 high = double (intmax (C)); | |
45 yiq = (double (yiq) - low) / (high - low); | |
46 endif | |
47 else | |
48 is_image = false; | |
49 endif | |
50 | |
51 if (! ismatrix (yiq) || columns (yiq) != 3) | |
52 error ("ntsc2rgb: argument must be a matrix of size Nx3 or NxMx3"); | |
53 endif | |
11587
c792872f8942
all script files: untabify and strip trailing whitespace
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
54 |
7375 | 55 ## Convert data |
1024 | 56 trans = [ 1.0, 1.0, 1.0; |
57 0.95617, -0.27269, -1.10374; | |
58 0.62143, -0.64681, 1.70062 ]; | |
559 | 59 |
60 rgb = yiq * trans; | |
61 | |
7375 | 62 ## If input was an image, convert it back into one. |
63 if (is_image) | |
64 rgb = reshape (rgb, Sz); | |
65 endif | |
66 | |
559 | 67 endfunction |