function makeDepthImages(dataNumber, displayFlag) % 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/ % This code could be used to align and view the depthmaps. % This code does nothing in the features / learning algorithm as such. if nargin < 2 displayFlag = false; end if nargin < 1 dataNumber = 1; end centerAngle = -180 + dataNumber*40; %Win05: Recalculate these numbers by looking at images and depthmaps laserAngleScan = 30; topAngle = 69; botAngle = 73; leftAngle = 10; rightAngle = 7; horThetaStep = 0.5; close all; directory = '~/scratch/LaserImage2DData/'; %Win05: % system([ 'cat ' depthDirectory depthFilename ' | sed s/PTLASER/\/g | cat > ' depthDirectory depthFilename 'cleaned']); % Above command is passed in Linux to clear the text, leaving only numbers, which can be directly % imported into Matlab by using File > Import Data load([directory 'log' num2str(dataNumber) '.mat']); A = imread([directory 'img-' num2str(dataNumber) '.jpg']); sizeHor = round( (-min(logDepth(:,2)) + max(logDepth(:,2) ) )/ horThetaStep ); quantizedLogDepth = zeros( sizeHor, size(logDepth,2)-4 ); angleIndex = 0; for x = (centerAngle-laserAngleScan):horThetaStep:(centerAngle+laserAngleScan) [tmp ind] = min( abs( logDepth(:,2) - x) ); %Win05: I remember 2nd column contained the time stamp, therefore it basically matches % the timestamp %IMPROVEMENT: instead of nearest one, do AVERAGING angleIndex = angleIndex + 1; quantizedLogDepth(angleIndex,:) = logDepth(ind, 5:size(logDepth,2) ); %Win05: 5 because first 4 numbers are not useful end clippedDepth = quantizedLogDepth( size(quantizedLogDepth,1):-1:1, ... (size(quantizedLogDepth,2)-topAngle):-1:(botAngle) )'; min(clippedDepth(:)); depthMap = log(clippedDepth); %depthImg = clippedDepth .^ (1/3); if displayFlag %subplot(1,2,1); image(A); axis square; %subplot(1,2,2); figure, imagesc( depthMap( :, leftAngle:(size(depthMap,2)-rightAngle) ) .^ (1/3) ); axis square; end directory = 'depthMapData/'; save([directory 'calculatedDepthData-' num2str(dataNumber) '.mat'], 'depthMap' ); imwrite( depthMap/ max(depthMap(:) ), [directory 'calculatedDepthImgSet2-' num2str(dataNumber) '.jpg']);