-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapplycform.sci
65 lines (60 loc) · 2.55 KB
/
applycform.sci
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright (C) 2015 - IIT Bombay - FOSSEE
//
// This file must be used under the terms of the CeCILL.
// This source file is licensed as described in the file COPYING, which
// you should have received as part of this distribution. The terms
// are also available at
// http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
// Author: Gursimar Singh,Tess Zacharias
// Organization: FOSSEE, IIT Bombay
// Email: [email protected]
function [outImg] = applycform(srcImg,transform)
//Apply device-independent color space transformation.
//
//Calling Sequence
//[outImg]=applycform(srcImage,transform)
//
//Parameters
//outImg:Output transformed image same number of channels as Input,Depth 8U.
//srcImage:Input image
//transform:Transformation string given as inputColorspace2ouptutColorspace.Valid strings are-<itemizedlist><listitem><para>'xyz2lab' :Convert from the XYZ to the L*a*b color space.</para></listitem><listitem><para>'lab2xyz' :Convert from the L*a*b to the XYZ color space.</para></listitem><listitem><para>'srgb2xyz' :Convert from the standard-RGB to the XYZ color space.</para></listitem><listitem><para>'xyz2srgb' :Convert from the XYZ to the standard-RGB color space.</para></listitem><listitem><para>'srgb2lab' :Convert from the standard-RGB to the L*a*b color space.</para></listitem><listitem><para>'lab2srgb' :Convert from the L*a*b to the standard-RGB color space.</para></listitem><listitem><para>'xyz2uvl' :Convert from the XYZ to the uvL color space.</para></listitem><listitem><para>'uvl2xyz' :Convert from the uvL to the XYZ color space.</para></listitem></itemizedlist>
//
//Description
//outImg = applycform(srcImage,transform) converts the color values in srcImage to the color space specified in the color transformation string transfrom.
//
//Examples
//im=imread("images/lena.jpeg",1);
//img=applycform(im,"srgb2xyz");
//imshow(img);
//
//Examples
//im=imread("images/lena.jpeg",1);
//img=applycform(im,"srgb2xyz");
//img=applycform(img,"xyz2uvl");
//img=applycform(img,"uvl2xyz");
//img=applycform(img,"xyz2srgb");
//imshow(img);
//
//Authors
//Gursimar Singh
//Tess Zacharias
[lhs,rhs]=argn(0);
if rhs>2 then
error(msprintf("Too many input arguments"));
end
if rhs<2 then
error(msprintf("Not enough input arguments"));
end
if lhs >1
error(msprintf("Too many output arguments"));
end
srcMat = mattolist(srcImg)
if size(srcImg)==1 then
error(msprintf("NUmber of channels of input image must be 3 or 4"));
end
out = raw_applycform(srcMat,transform)
sz=size(out)
for i=1:sz
outImg(:,:,i)=out(i);
end
endfunction