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

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

Added original make3d

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