Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 1ee22639 authored by DIB Elian's avatar DIB Elian
Browse files

Added function to compute super-rays coordinates from affine parameters

parent 333874aa
Branches
No related tags found
No related merge requests found
function [SRXq,SRYq,SRDisp] = getQueryCoordsAffineOptimized(LFRef,dispParams)
%GETQUERYCOORDSAFFINE Summary of this function goes here
% Detailed explanation goes here
%%
%% Initialize constants and interpolants
% Lightfield properties
LFSize = size(LFRef.Color);
ImgRes = LFSize(4:end);
Label = LFRef.Label;
centerView = floor(ImgRes/2)+1;
numLab = max(Label(:));
% Replace missing values by zero (to avoid interpolation errors)
Label(isnan(Label))=0;
% Compute projected coordinates of reference samples
gv = arrayfun(@(x) 1:x,LFSize,'UniformOutput',false);
gv{3} = 1;
ugv = reshape(gv{4},1,1,1,[],1);
vgv = reshape(gv{5},1,1,1,1,[]);
ugv = ugv-centerView(1);
vgv = vgv-centerView(2);
%%
[X,Y,~,U,V] = ndgrid(gv{:});
U = U-centerView(1);
V = V-centerView(2);
%%
[SRXq,SRYq,SRDisp] = deal(cell(1,numLab));
%% Remove entries corresponding to missing labels in accordance to loadReference
ind = ~cellfun(@isempty,dispParams);
dispParams = dispParams(ind);
%%
fprintf('Super-ray sampling coordinates computation...\n');
%%
progress('',0);
for lab = 1:numLab
msg = ['Initializing super-ray ',num2str(lab),'/',num2str(numLab),'\n'];
progress(msg);
M = Label==lab;
a = dispParams{lab}(1);
b = dispParams{lab}(2);
c = dispParams{lab}(3);
X_ = X(M(:));
Y_ = Y(M(:));
U_ = U(M(:));
V_ = V(M(:));
tX = X_-U_.*(a.*X_+b.*Y_+c)./( 1+a.*U_+b.*V_);
tY = Y_-V_.*(a.*X_+b.*Y_+c)./( 1+a.*U_+b.*V_);
srxgv = floor(min(tX(:))):ceil(max(tX(:)));
srygv = floor(min(tY(:))):ceil(max(tY(:)));
[X_,Y_] = ndgrid(srxgv,srygv);
D_ = a.*X_+b.*Y_+c;
D_ = reshape(D_,size(X_));
[SRXq{lab},SRYq{lab}] = ndgrid(srxgv,srygv,gv{3:end});
SRXq{lab} = SRXq{lab}+ugv.*D_;
SRYq{lab} = SRYq{lab}+vgv.*D_;
SRDisp{lab} = ones(size(SRXq{lab})).*D_;
end
progress('',0);
fprintf('\n');
function progress(msg,varargin)
persistent sz
if isempty(sz); sz = 0; end
if nargin>1; sz = varargin{1}; end
fprintf(repmat('\b',1,sz));
fprintf(msg);
sz = numel(msg)-count(msg,'\n');
end
end
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment