您现在的位置:首页 >> 技术文章 >> MATLAB技术 >> 内容

MATLAB代做|FPGA代做-光滑球体中光斑的提取

时间:2021-1-17 6:21:04 点击:

  核心提示:MATLAB代做|FPGA代做-光滑球体中光斑的提取...

function l = FindLightDirectionFromChromeSphere(I, circle, threshold, options)

 

% l = FindLightDirectionFromChromeSphere(I, circle, threshold)

%

% Find the light source direction from the given image of a light sphere, using

% the specular highlights. The code assumes an orthographic camera model. The

% coordinate system origins at the object sphere, with camera direction (0,0,1).

% In the camera point of view, it is looking at the sphere in (0,0,-1) direction.

%

% INPUT:

%   I: the image of a specular chrome sphere.

%   circle: a 3x1 vector [xc; yc; r] describing the position of chrome sphere.

%   threshold: the threshold for specular highlights, e.g. 250 for a 8-bit

%              image. This is an inclusive threshold, meaning that any intensity

%              >= 'threshold' will be considered as outlier.

%   options: a struct with following supported fields:

%     'Visualize': whether to do visualization or not, options {'off'} or 'on'.

%                  If set 'on', the visualization will be on 'gca'.

%

% OUTPUT:

%   l: the estimated light source direction, 3x1 unit vector.

%

%   Author: Ying Xiong.

%   Created: Jan 24, 2014.

 

if (~exist('options', 'var'))   options = [];   end

 

% Convert to gray scale image.

if (size(I, 3) == 3)

  I = rgb2gray(I);

end

 

% Get the circle info.

xc = circle(1);

yc = circle(2);

r = circle(3);

 

% Find the specular highlight center.

[hy, hx] = ind2sub(size(I), find(I>=threshold));

hxc = median(hx);

hyc = median(hy);

 

% The normal vector of highlight on the sphere.

n = [hxc - xc; hyc - yc] / r;

n(3) = sqrt(1 - n(1)^2 - n(2)^2);

 

% Find the light source direction, which has the same angle with normal and

% with viewing direction (0,0,1).

l = 2*n(3)*n - [0; 0; 1];

 

if (isfield(options, 'Visualize') && strcmp(options.Visualize, 'on'))

  imshow(I); axis xy; hold on;

  t = 0:0.01:2*pi;

  plot(xc + r*cos(t), yc + r*sin(t));

  plot(hxc, hyc, 'r*');

end

联系:highspeedlogic

QQ :1224848052

微信:HuangL1121

邮箱:1224848052@qq.com

网站:http://www.mat7lab.com/

网站:http://www.hslogic.com/

微信扫一扫:

 

作者:光滑球体中光斑的提取 来源:光滑球体中光斑的提取
  • 您是如何找到本站的?
  • 百度搜索
  • Google搜索
  • 查阅资料过程中
  • 论坛发现
  • 百度贴吧发现
  • 朋友介绍
本站最新成功开发工程项目案例
相关评论
发表我的评论
  • 大名:
  • 内容:
  • matlab代做|matlab专业代做|matlab淘宝代做|python人工智能代做|FPGA项目合作|C代做|C++代做(www.hslogic.com) © 2021 版权所有 All Rights Reserved.
  • Email:highspeed_logic@163.com 站长QQ: 1224848052

    专业代做/代写/承接、MATLAB、SIMULINK、FPGA项目、博士/硕士/本科毕业设计、课题设计、论文,毕业论文,Coursework、Eassy、Assignment