diff --git a/getQueryCoordsAffineOptimized.m b/get_affine_query_coordinates.m similarity index 67% rename from getQueryCoordsAffineOptimized.m rename to get_affine_query_coordinates.m index 119e732edd000fdc66881359e668e0b1a0685f7a..2c08d0ad3c861988fd6c0fb9d98d8e701fdf38f4 100644 --- a/getQueryCoordsAffineOptimized.m +++ b/get_affine_query_coordinates.m @@ -1,43 +1,26 @@ -function [SRXq,SRYq,SRDisp] = getQueryCoordsAffineOptimized(LFRef,dispParams) -%GETQUERYCOORDSAFFINE Summary of this function goes here +function [SRXq,SRYq,SRDisp] = get_affine_query_coordinates(Label,lfgv,dispParams) +%GET_AFFINE_QUERY_COORDINATES 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(:)); +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) 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 +% 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']; @@ -64,7 +47,7 @@ for lab = 1:numLab D_ = a.*X_+b.*Y_+c; 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_; SRYq{lab} = SRYq{lab}+vgv.*D_;