Mentions légales du service

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

Changed getQueryCoordsAffineOptimized to get_affine_query_coordinates

Simplified the code
parent 1ee22639
No related branches found
No related tags found
No related merge requests found
function [SRXq,SRYq,SRDisp] = getQueryCoordsAffineOptimized(LFRef,dispParams) function [SRXq,SRYq,SRDisp] = get_affine_query_coordinates(Label,lfgv,dispParams)
%GETQUERYCOORDSAFFINE Summary of this function goes here %GET_AFFINE_QUERY_COORDINATES Summary of this function goes here
% Detailed explanation goes here % Detailed explanation goes here
%% %%
%% Initialize constants and interpolants %% Initialize constants and interpolants
% Lightfield properties % Lightfield properties
LFSize = size(LFRef.Color);
ImgRes = LFSize(4:end);
Label = LFRef.Label;
centerView = floor(ImgRes/2)+1;
numLab = max(Label(:)); numLab = max(Label(:));
lfgv{3} = 1;
ugv = reshape(lfgv{4},1,1,1,[],1);
vgv = reshape(lfgv{5},1,1,1,1,[]);
[X,Y,~,U,V] = ndgrid(lfgv{:});
[SRXq,SRYq,SRDisp] = deal(cell(1,numLab));
% Replace missing values by zero (to avoid interpolation errors) % Replace missing values by zero (to avoid interpolation errors)
Label(isnan(Label))=0; Label(isnan(Label))=0;
% Compute projected coordinates of reference samples % Remove entries corresponding to missing labels in accordance to loadReference
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); ind = ~cellfun(@isempty,dispParams);
dispParams = dispParams(ind); dispParams = dispParams(ind);
%% %%
fprintf('Super-ray sampling coordinates computation...\n'); fprintf('Super-ray sampling coordinates computation...\n');
%%
progress('',0); progress('',0);
for lab = 1:numLab for lab = 1:numLab
msg = ['Initializing super-ray ',num2str(lab),'/',num2str(numLab),'\n']; msg = ['Initializing super-ray ',num2str(lab),'/',num2str(numLab),'\n'];
...@@ -64,7 +47,7 @@ for lab = 1:numLab ...@@ -64,7 +47,7 @@ for lab = 1:numLab
D_ = a.*X_+b.*Y_+c; D_ = a.*X_+b.*Y_+c;
D_ = reshape(D_,size(X_)); D_ = reshape(D_,size(X_));
[SRXq{lab},SRYq{lab}] = ndgrid(srxgv,srygv,gv{3:end}); [SRXq{lab},SRYq{lab}] = ndgrid(srxgv,srygv,lfgv{3:end});
SRXq{lab} = SRXq{lab}+ugv.*D_; SRXq{lab} = SRXq{lab}+ugv.*D_;
SRYq{lab} = SRYq{lab}+vgv.*D_; SRYq{lab} = SRYq{lab}+vgv.*D_;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment