function permutedFeatureVectors = makeAppendedRelativeFeatures(rownumber, image, scales) % Version 0.1, Feb 2006. % This code is copyrighted by Ashutosh Saxena, Stanford University % It is available for non-commercial use only. For commericial use, please % contact the authors. % Any publication or report resulting from Use of this code, should cite: % Learning Depth from Single Monocular Images, Ashutosh Saxena, Sung H. Chung, Andrew Y. Ng, NIPS 2005. % 3-D Depth Reconstruction from a Single Still Image, Ashutosh Saxena, Sung H. Chung, Andrew Y. Ng, To appear in IJCV 2007. % For more info and dataset, visit: http://ai.stanford.edu/~asaxena/learningdepth/ % For a better version of the algorithm, also visit: % http://ai.stanford.edu/~asaxena/reconstruction3d/ global nGridRow nGridCol featureDirectory global nStatistics configurationFile; numStatistics = nStatistics; % Per scale numfeatures = 170; % Scales must follow the order of scales in the mat file numscales = length(scales); load([featureDirectory 'allTrainingRelativeFeatureData_row' ... num2str(rownumber) '_' num2str(image) '.mat']); currowFeatureVector = rowRelativeFeatureVector; numimages = size(currowFeatureVector, 4); numcolumns = size(currowFeatureVector, 2); numNeighbors = 3; % middle, bot, right order permutedFeatureVectors = zeros(1, numcolumns, ... numNeighbors*numscales*numfeatures, numimages); % Let's load all the necessary feature vectors for z=1:numscales curscale = scales(z); k = 0; if curscale == 1 k = 1; elseif curscale == 2 k = 2; elseif curscale == 4 k = 3; else display('Should not get here !'); end % offset = 1; % if curscale == 2 % offset = (curscale - 1)*2 + 1; % end offset = 3; botrow = rownumber + offset; if botrow > nGridRow botrow = nGridRow; end % The feature at the center permutedFeatureVectors(1, :, ... (numNeighbors*numfeatures*(z-1)+1):(numNeighbors*numfeatures*(z-1)+numfeatures), :) = ... currowFeatureVector(1, :, ((k-1)*numfeatures+1):(k*numfeatures), :); % The feature at the bottom load([featureDirectory 'allTrainingRelativeFeatureData_row' num2str(botrow) '_' ... num2str(image) '.mat']); permutedFeatureVectors(1, :, ... (numNeighbors*numfeatures*(z-1)+numfeatures+1):(numNeighbors*numfeatures*(z-1)+2*numfeatures), :) = ... rowRelativeFeatureVector(1, :, ((k-1)*numfeatures+1):(k*numfeatures), :); % The feature to the right perm = zeros(1, numcolumns); for h=1:numcolumns if (h+offset) > numcolumns perm(1,h) = numcolumns; else perm(1,h) = h + offset; end end permutedFeatureVectors(1, :, ... (numNeighbors*numfeatures*(z-1)+2*numfeatures+1):(numNeighbors*numfeatures*(z-1)+3*numfeatures), :) = ... currowFeatureVector(1, perm, ((k-1)*numfeatures+1):(k*numfeatures), :); end