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

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

Added original make3d

File size: 1.7 KB
Line 
1function J=xyz2rgb(I,ws)
2% XYZ2RGB  Convert XYZ to RGB
3%   J = XYZ2RGB(I) the XYZ image I in RGB format.
4%
5%   XYZ2RGB(I,WS) uses the specified RGB working space WS. The function
6%   supports the following RGB working spaces:
7%
8%   - `CIE'    E illuminant, gamma=2.2
9%   - `Adobe'  D65 illuminant, gamma=2.2
10%
11%   The default is CIE.
12%
13%   See also RGB2XYZ().
14
15% AUTORIGHTS
16% Copyright (C) 2006 Andrea Vedaldi
17%       
18% This file is part of VLUtil.
19%
20% VLUtil is free software; you can redistribute it and/or modify
21% it under the terms of the GNU General Public License as published by
22% the Free Software Foundation; either version 2, or (at your option)
23% any later version.
24%
25% This program is distributed in the hope that it will be useful,
26% but WITHOUT ANY WARRANTY; without even the implied warranty of
27% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
28% GNU General Public License for more details.
29%
30% You should have received a copy of the GNU General Public License
31% along with this program; if not, write to the Free Software Foundation,
32% Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
33
34if(nargin < 2)
35  workspace = 'CIE' ;
36else
37  workspace = ws ;
38end
39
40switch workspace
41  case 'CIE'   
42    % CIE: E illuminant and 2.2 gamma
43    A = [
44      0.488718    0.176204    0.000000   
45      0.310680    0.812985    0.0102048 
46      0.200602     0.0108109  0.989795 ]' ;
47    gamma = 2.2 ;
48   
49  case 'Adobe'
50    % Adobe 1998: D65 illuminant and 2.2 gamma
51    A = [
52      0.576700    0.297361    0.0270328 
53      0.185556    0.627355    0.0706879 
54      0.188212    0.0752847   0.99124 ]' ;
55    gamma = 2.2 ;
56end
57
58[M,N,K] = size(I) ;
59
60I = reshape(I, M*N, K) ;
61J = inv(A)*I' ;
62J = reshape(J'.^(1/gamma), M, N, K) ;
Note: See TracBrowser for help on using the repository browser.