function [featureVector] = makeColumnFeatureTexture(img, type, numpartitions) % 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/ persistent L3 E3 S3 L5 L7 gMask % the Laws' masks global columnWidth nGridCol nGridRow rowWidth global scale2Factor global nLaw nDim nHarris if nargin < 3 numpartitions = 40; end if nargin < 2 type = 'texture'; end nGCol = nGridCol; nGRow = nGridRow; % Assume that the image is correctly oriented. imheight = size(img, 1); imwidth = size(img, 2); % Step sizes in x and y stepwidth = imwidth/nGridCol; stepheight = imheight/nGridRow; H2 = calculateFilterBanks(img, type); %columnfeatures = zeros(numpartitions, 2*nLaw+3*nHarris); columnfeatures = zeros(1, numpartitions, nLaw); % column step size colstepsize = round(imwidth / numpartitions); for step=1:numpartitions colLeft = round( (step - 1)*colstepsize + 1 ); colRight = round( step*colstepsize ); if colRight > imwidth colRight = imwidth; end if nLaw % This old version of the code uses 1 patch for column feature vector, modify to match it with one in NIPS and IJCV paper. columnfeatures(1, step, 1:nLaw) = sum( sum( H2( :, colLeft:colRight, 1:nLaw), 2), 1); % columnfeatures(step, nLaw+(1:nLaw)) = sum( sum( H4( :, colLeft:colRight, 1:nLaw), 2), 1); end if nHarris % Do Harris here if need to. end end %featureVectorTmp = zeros( nGRow, nGCol, 2*nLaw+3*nHarris); featureVectorTmp = zeros( nGRow, nGCol, nLaw); for g=1:nGRow for c=1:nGCol choice = floor((c*stepwidth)/colstepsize) + 1; if choice > numpartitions choice = numpartitions; end featureVectorTmp(g,c,:) = columnfeatures(1, choice,:); end end featureVector = featureVectorTmp; return;