source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/vlutil/toolbox/xyz2luv.m @ 37

Last change on this file since 37 was 37, checked in by (none), 14 years ago

Added original make3d

File size: 2.1 KB
Line 
1function J=xyz2luv(I,illuminant)
2% XYZ2LUV  Convedrt XYZ to LUV
3%   J = XYZ2LUV(I) converts the image I in XYZ format to  the Luv format
4%   (using by default the illuminant E).
5%
6%   J = XYZ2LUV(I,illuminant) uses the specified illuminant. The following
7%   illuminant are supported: A, B, C, E, D50, D55, D65, D75, D93.
8%
9%   See also XYZ2LAB().
10
11% AUTORIGHTS
12% Copyright (C) 2006 Andrea Vedaldi
13%       
14% This file is part of VLUtil.
15%
16% VLUtil is free software; you can redistribute it and/or modify
17% it under the terms of the GNU General Public License as published by
18% the Free Software Foundation; either version 2, or (at your option)
19% any later version.
20%
21% This program is distributed in the hope that it will be useful,
22% but WITHOUT ANY WARRANTY; without even the implied warranty of
23% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24% GNU General Public License for more details.
25%
26% You should have received a copy of the GNU General Public License
27% along with this program; if not, write to the Free Software Foundation,
28% Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29
30if nargin < 2
31  illuminant='E' ;
32end
33
34switch illuminant
35  case 'A'
36    xw = 0.4476 ;
37    yw = 0.4074 ; 
38  case 'B'
39    xw = 0.3324 ;
40    yw = 0.3474 ;
41  case 'C'
42    xw = 0.3101 ;
43    yw = 0.3162 ;
44  case 'E'
45    xw = 1/3 ;
46    yw = 1/3 ;
47  case 'D50'
48    xw = 0.3457 ;
49    yw = 0.3585 ;
50  case 'D55'
51    xw = 0.3324 ;
52    yw = 0.3474 ;
53  case 'D65'
54    xw = 0.312713 ;
55    yw = 0.329016 ;
56  case 'D75'
57    xw = 0.299 ;
58    yw = 0.3149 ;
59  case 'D93'
60    xw = 0.2848 ;
61    yw = 0.2932 ;
62end
63
64J=zeros(size(I)) ;
65
66% Reference white
67xw = 1/3 ;
68yw = 1/3 ;
69Yw = 1.0 ;
70Xw = xw/yw ;
71Zw = (1-xw-yw)/yw * Yw ;
72
73J=zeros(size(I)) ;
74
75X = I(:,:,1) ;
76Y = I(:,:,2) ;
77Z = I(:,:,3) ;
78
79upw = 4*Xw / (Xw + 15*Yw + 3*Zw) ;
80vpw = 9*Yw / (Xw + 15*Yw + 3*Zw) ;
81
82up = 4*X ./ (X + 15*Y + 3*Z) ;
83vp = 9*Y ./ (X + 15*Y + 3*Z) ;
84
85sp = find( Y / Yw  > 0.008856) ;
86sm = find( Y / Yw <= 0.008856) ;
87
88L = zeros(size(Y)) ;
89L(sp) =   116*( Y(sp) / Yw ).^(1/3) - 16 ;
90L(sm) = 903.3*( Y(sm) / Yw ) ;
91
92u = 13 * L .* (up - upw) ;
93v = 13 * L .* (vp - vpw) ;
94
95J = cat(3,L,u,v) ;
Note: See TracBrowser for help on using the repository browser.