代码拉取完成,页面将自动刷新
同步操作将从 陈帅/ShadowRemoval 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
function bd = getbd(msk,fsp)
%GETBD obtains the boundary of shadow
%
% Function is written by Han Gong, University of Bath, UK
imhw = size(msk); % size of image
% get boundaries of sampling areas
[bdp,~,N] = bwboundaries(msk); % boundary
bdl = cellfun(@(x) size(x,1),bdp); % length of each boundary
pl = find(bdl>3); % remove too short boundaries
bdpf = bdp(pl); % filtered boundaries
bdnf = cell(size(bdpf)); % boundary normal
bdtf = cell(size(bdpf)); % type of boundary point
bdmf = cell(size(bdpf)); % maker of boudnary number
for i = 1:length(pl)
cbd = flipud(bdpf{i}'); ptlen = size(cbd,2); % current bondary
% compute boundary normal
t = cumsum([0,sqrt((sum(diff(cbd,1,2).^2)))]); % x^2+y^2 计算边界长度
cv = csaps(t,cbd,1/(1 + fsp^3/0.6)); %拟合出长度与位置的关系
v = fntlr(cv,2,t); % derivatie vector 泰勒2阶系数,即是该点数据以及一阶导
R = [0,1;-1,0]; if pl(i)>N, R = -R; end % rotation matrix
cbdn = R*v(3:4,:); % normal vector
cbdn = bsxfun(@rdivide,cbdn,sqrt(sum(cbdn.^2)));
% exclude boudnary at image boarder
bm = cbd(1,:)==1|cbd(1,:)==imhw(2)|cbd(2,:)==1|cbd(2,:)==imhw(1);
cdt = zeros(ptlen,1); cdt(bm) = -1; % mark points at image boarder
% curature sampling
npt = fnval(cv,t); ksp = 20;
curv = cumsum(sat(abs(LineCurvature2D(npt')),0,ksp)); curv = curv/ksp;
clidx = [1;find(diff(fix(curv),1)>0);ptlen]; % selected bounday index
lidx = union(transpose(1:fsp:ptlen),clidx); % combined boundary index
bdpf{i} = transpose(cbd(:,lidx)); bdnf{i} = transpose(cbdn(:,lidx));
bdtf{i} = cdt(lidx); bdmf{i} = ones(numel(lidx),1)*i;
end
bd.p = transpose(cell2mat(bdpf)); bd.n = transpose(cell2mat(bdnf));
bd.t = cell2mat(bdtf); bd.m = cell2mat(bdmf);
end
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。