% void CLASS cam_xyz_coeff (float rgb_cam[3][4], double cam_xyz[4][3])
% {
% double cam_rgb[4][3], inverse[4][3], num;
% int i, j, k;
%
% for (i=0; i < colors; i++) /* Multiply out XYZ colorspace /
% for (j=0; j < 3; j++)
% for (cam_rgb[i][j] = k=0; k < 3; k++)
% cam_rgb[i][j] += cam_xyz[i][k]
xyz_rgb[k][j];
%
% for (i=0; i < colors; i++) { /* Normalize cam_rgb so that /
% for (num=j=0; j < 3; j++) /
cam_rgb * (1,1,1) is (1,1,1,1) */
% num += cam_rgb[i][j];
% for (j=0; j < 3; j++)
% cam_rgb[i][j] /= num;
% pre_mul[i] = 1 / num;
% }
% pseudoinverse (cam_rgb, inverse, colors);
% for (i=0; i < 3; i++)
% for (j=0; j < colors; j++)
% rgb_cam[i][j] = inverse[j][i];
% }

% void CLASS pseudoinverse (double (in)[3], double (out)[3], int size)
% {
% double work[3][6], num;
% int i, j, k;
%
% for (i=0; i < 3; i++) {
% for (j=0; j < 6; j++)
% work[i][j] = j == i+3;
% for (j=0; j < 3; j++)
% for (k=0; k < size; k++)
% work[i][j] += in[k][i] * in[k][j];
% }
% for (i=0; i < 3; i++) {
% num = work[i][i];
% for (j=0; j < 6; j++)
% work[i][j] /= num;
% for (k=0; k < 3; k++) {
% if (k==i) continue;
% num = work[k][i];
% for (j=0; j < 6; j++)
% work[k][j] -= work[i][j] * num;
% }
% }
% for (i=0; i < size; i++)
% for (j=0; j < 3; j++)
% for (out[i][j]=k=0; k < 3; k++)
% out[i][j] += work[j][k+3] * in[i][k];
% }

% const double xyz_rgb[3][3] = { /* XYZ from RGB */
% { 0.412453, 0.357580, 0.180423 },
% { 0.212671, 0.715160, 0.072169 },
% { 0.019334, 0.119193, 0.950227 } };
clc
clear all
cmsrc0 = [1.895316, -0.688256,-0.20706;
-0.180953,1.625399,-0.444446;
-0.0000147,-0.524012,1.524159;
0,0,0]

cam_xyz = [0.617188, -0.140625, -0.0390625;
-0.460938, 1.19531, 0.226563;
-0.0859375, 0.1953113, 0.545875;
0,0,0
];

cam_rgb = zeros(4,3);
inverse = zeros(4,3);
xyz_rgb = [0.412453, 0.357580, 0.180423,0;
0.212671, 0.715160, 0.072169,0;
0.019334, 0.119193, 0.950227,0];
cam_rgb = cam_xyz * xyz_rgb;
for i =1:3
cam_rgb(i,:) = cam_rgb(i,:) / sum(cam_rgb(i,:));
end
cam_rgb = cam_rgb(:,1:3);
colors = 3;

x11 = cam_rgb(1,1);
x12 = cam_rgb(1,2);
x13 = cam_rgb(1,3);
x21 = cam_rgb(2,1);
x22 = cam_rgb(2,2);
x23 = cam_rgb(2,3);
x31 = cam_rgb(3,1);
x32 = cam_rgb(3,2);
x33 = cam_rgb(3,3);
work = zeros(3,6);
work(1,1) = x11 x11 + x21 x21 + x31 * x31;
work(1,2) = x11 x12 + x21 x22 + x31 * x32;
work(1,3) = x11 x13 + x21 x23 + x31 * x33;
work(2,1) = x11 x12 + x21 x22 + x31 * x32;
work(2,2) = x12 x12 + x22 x22 + x32 * x32;
work(2,3) = x12 x13 + x22 x23 + x32 * x33;
work(3,1) = x11 x13 + x21 x23 + x31 * x33;
work(3,2) = x12 x13 + x22 x23 + x32 * x33;
work(3,3) = x13 x13 + x23 x23 + x33 * x33;
work(:,4:6) = [1,0,0;0,1,0;0,0,1];

% i =1
num1 = work(1,1);
work(1,1) = work(1,1) / num1;
work(1,2) = work(1,2) / num1;
work(1,3) = work(1,3) / num1;
work(1,4) = work(1,4) / num1;
work(1,5) = work(1,5) / num1;
work(1,6) = work(1,6) / num1;

% k = 2
num2 = work(2,1);
work(2,1) = work(2,1) - num2 * work(1,1);
work(2,2) = work(2,2) - num2 * work(1,2);
work(2,3) = work(2,3) - num2 * work(1,3);
work(2,4) = work(2,4) - num2 * work(1,4);
work(2,5) = work(2,5) - num2 * work(1,5);
work(2,6) = work(2,6) - num2 * work(1,6);

% k = 3
num3 = work(3,1);
work(3,1) = work(3,1) - num3 * work(1,1);
work(3,2) = work(3,2) - num3 * work(1,2);
work(3,3) = work(3,3) - num3 * work(1,3);
work(3,4) = work(3,4) - num3 * work(1,4);
work(3,5) = work(3,5) - num3 * work(1,5);
work(3,6) = work(3,6) - num3 * work(1,6);

% i = 2
num1 = work(2,2);
work(2,1) = work(2,1) / num1;
work(2,2) = work(2,2) / num1;
work(2,3) = work(2,3) / num1;
work(2,4) = work(2,4) / num1;
work(2,5) = work(2,5) / num1;
work(2,6) = work(2,6) / num1;

num2 = work(1,2);
work(1,1) = work(1,1) - num2 * work(2,1);
work(1,2) = work(1,2) - num2 * work(2,2);
work(1,3) = work(1,3) - num2 * work(2,3);
work(1,4) = work(1,4) - num2 * work(2,4);
work(1,5) = work(1,5) - num2 * work(2,5);
work(1,6) = work(1,6) - num2 * work(2,6);

num3 = work(3,2);
work(3,1) = work(3,1) - num3 * work(2,1);
work(3,2) = work(3,2) - num3 * work(2,2);
work(3,3) = work(3,3) - num3 * work(2,3);
work(3,4) = work(3,4) - num3 * work(2,4);
work(3,5) = work(3,5) - num3 * work(2,5);
work(3,6) = work(3,6) - num3 * work(2,6);

% i = 3
num1 = work(3,3);
work(3,1) = work(3,1) / num1;
work(3,2) = work(3,2) / num1;
work(3,3) = work(3,3) / num1;
work(3,4) = work(3,4) / num1;
work(3,5) = work(3,5) / num1;
work(3,6) = work(3,6) / num1;

num2 = work(1,3);
work(1,1) = work(1,1) - num2 * work(3,1);
work(1,2) = work(1,2) - num2 * work(3,2);
work(1,3) = work(1,3) - num2 * work(3,3);
work(1,4) = work(1,4) - num2 * work(3,4);
work(1,5) = work(1,5) - num2 * work(3,5);
work(1,6) = work(1,6) - num2 * work(3,6);

num3 = work(2,3);
work(2,1) = work(2,1) - num3 * work(3,1);
work(2,2) = work(2,2) - num3 * work(3,2);
work(2,3) = work(2,3) - num3 * work(3,3);
work(2,4) = work(2,4) - num3 * work(3,4);
work(2,5) = work(2,5) - num3 * work(3,5);
work(2,6) = work(2,6) - num3 * work(3,6);

out = zeros(3,3);
out(1,1) = work(1,4) * cam_rgb(1,1) + work(1,5) * cam_rgb(1,2) + work(1,6) * cam_rgb(1,3);
out(1,2) = work(2,4) * cam_rgb(1,1) + work(2,5) * cam_rgb(1,2) + work(2,6) * cam_rgb(1,3);
out(1,3) = work(3,4) * cam_rgb(1,1) + work(3,5) * cam_rgb(1,2) + work(3,6) * cam_rgb(1,3);
out(2,1) = work(1,4) * cam_rgb(2,1) + work(1,5) * cam_rgb(2,2) + work(1,6) * cam_rgb(2,3);
out(2,2) = work(2,4) * cam_rgb(2,1) + work(2,5) * cam_rgb(2,2) + work(2,6) * cam_rgb(2,3);
out(2,3) = work(3,4) * cam_rgb(2,1) + work(3,5) * cam_rgb(2,2) + work(3,6) * cam_rgb(2,3);
out(3,1) = work(1,4) * cam_rgb(3,1) + work(1,5) * cam_rgb(3,2) + work(1,6) * cam_rgb(3,3);
out(3,2) = work(2,4) * cam_rgb(3,1) + work(2,5) * cam_rgb(3,2) + work(2,6) * cam_rgb(3,3);
out(3,3) = work(3,4) * cam_rgb(3,1) + work(3,5) * cam_rgb(3,2) + work(3,6) * cam_rgb(3,3);
out'

% work = zeros(3,6);
% for i =1:3
% for j = 1:6
% if j == i+3
% work(i,j) = 1;
% else
% work(i,j) = 0;
% end
% end
%
% for j = 1:3
% for k = 1:colors
% work(i,j) = work(i,j) + cam_rgb(k,i) * cam_rgb(k,j);
% end
% end
% end
%
% for i =1:3
% num = work(i,i);
% for j = 1:6
% work(i,j) = work(i,j) / num;
% end
% for k = 1:3
% if(k == i)
% continue;
% end
% num = work(k,i);
% for j = 1:6
% work(k,j) = work(k,j) - work(i,j) * num;
% end
% end
% end

% out = zeros(3,3);
% for i = 1:colors
% for j =1:3
% out(i,j) =0;
% for k = 1:3
% out(i,j) = out(i,j) + work(j,k+3) * cam_rgb(i,k);
% end
% end
% end
%
% out = out'

ceshi的更多相关文章

  1. http://www.spasvo.com/ceshi/open/kyxncsgj/Jmeter/

    http://www.spasvo.com/ceshi/open/kyxncsgj/Jmeter/

  2. 解决Swap file &quot;.ceshi.c.swp&quot; already exists!问题

    关于swp文件:使用vi,常常能够看到swp这个文件,那这个文件是怎么产生的呢.当你打开一个文件,vi就会生成这么一个.(filename)swp文件以备不測,假设你正常退出,那么这个.(filena ...

  3. Fatal error: Call to undefined function Think\C() in /var/www/html/ceshi.hzheee.com/think/ThinkPHP/Library/Think/Think.class.php on line 334 这个问题解决

    当APP_DEBUG为true时,包含图中这个文件,文件中又引导包含这些库文件,可以看出安装thinkphp3.2.3时ThinkPHP/Common/下是functions.php,把它改成func ...

  4. laotech老师唠科mac 深入浅出MAC OS X ceshi ruguokeyi

    laotech老师唠科mac 深入浅出MAC OS X http://study.163.com/plan/planLearn.htm?id=1637004#/learn/resVideo?lesso ...

  5. Jquery的点击事件,三句代码完成全选事件

    先来看一下Js和Jquery的点击事件 举两个简单的例子 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN&q ...

  6. Jquery(1)

    鼠标点击事件: <input type="button" value="测试" onclick="test()" /> < ...

  7. JQuery实现表格的增加行和删除行

    利用JQuery实现datatables插件的增加和删除行操作 在学习过程中遇到了这个利用JQuery对表格行的增加和删除,特记录下来以供初学者参考. 下面是主要的代码: <meta http- ...

  8. Jquary入门(添加 修改 表单元素)+ JSON+弹框

    字符串拼接 计算机语言 都是 对  数据的处理(获取/修改数据)  添加元素  除了  固定的方法添加 以外 都是   字符串拼接(拼接成固定格式即可执行). 1.表单添加元素  append() 方 ...

  9. Jquery事件

    在JS里加事件  <input type="button" value="测试" onclick="test()"/>跟一个函数 ...

随机推荐

  1. python 反射

    python 反射的核心本质其实就是利用字符串的形式去对象(模块)中操作(查找/获取/删除/添加)成员,一种基于字符串的事件驱动! 反射的四个基本函数使用 hasattr,getattr,setatt ...

  2. vim保存文件时,生成.un~文件

    在用vim保存文件时,文件夹下生成.un~文件 怎么删除这些文件呢 在网上搜索的答案: http://stackoverflow.com/questions/15660669/what-is-a-un ...

  3. switch的使用

    ji本没用过这个函数,今天用到了它,发现了一些使用要注意的地方: switch的参数支持int和枚举,单jdk1.7后,开始支持String类型.我特意在jdk1.8上试了试, public clas ...

  4. 成功开发iPhone软件的10个步骤

    总结 几条要注意的原则: 1.了解你的用户,并与他们接触.交谈. 2.不要做虚幻的想象的设计,多从成功软件中汲取经验. 3.软件要设计得“小”. 4.找到足够多的设计方案,通过数量的累计来得到好的质量 ...

  5. nuget的搭建及多源冲突

    为什么使用nuget来管理类库引用就不再阐述,好处真的一抓一把.在使用nuget的时候,我们如果总去访问别人的nuget源,受限于网络情况的好坏,速度真的没法保证,更别说访问国外的源了.那好,我们来自 ...

  6. iOS9,导航控制器中的子控制器设置StatusBar状态失效的问题

    iOS9之前控制StatusBar的两种方式: 第一种方式:全局控制StatusBar 1. 在项目的Info.plist文件里设置UIViewControllerBasedStatusBarAppe ...

  7. jdbc链接数据库的三种方式

    /** * jdbc连接数据库 * @author APPle * */ public class Demo1 { //连接数据库的URL private String url = "jdb ...

  8. python ConfigParser 模块

    ConfigParser的函数方法 读取配置文件 read(filename) 直接读取ini文件内容 sections() 得到所有的section,并以列表的形式返回 options(sectio ...

  9. redis lua

    需求是在缓存最近一周内用户所有消息列表,考虑用Redis 存储:为每个存储一个独立Sorted Set,value 为消息体,Score 为MessageId,用以实现增量消息同步. 问题就来了:So ...

  10. css单位盘点

    css单位有:px,em,rem,vh,vw,vmin,vmax,ex,ch 等等 1.px单位最常见,也最直接,这里不做介绍. 2.em:em的值并不是固定,它继承父级元素的字体大小,所以层数越深字 ...