function makeDepthImageFromPoints(typeData) % This code is copyrighted by Stanford University. % Author: Ashutosh Saxena, Justin Drieymeyer % Code cannot be used for commercial purposes. % Use of the code, if used with permission from authors, must acknowledge: % Learning to Grasp Novel Objects using Vision, % Ashutosh Saxena, Justin Driemeyer, Justin Kearns, Chioma Osondu, Andrew Y. Ng. In 10th International Symposium on Experimental Robotics, ISER, 2006. % Robotic Grasping of Novel Obects, % Ashutosh Saxena, Justing Driemeyer, Justin Kearns, Andrew Y. Ng, In Neural Information Processing Systems (NIPS), 2006. % More details at: http://ai.stanford.edu/~asaxena/learninggrasp/ % Version 0.1: Aug 2006. if nargin < 1 typeData = 'emptyDishwasher'; end perceptionParameters; global syntheticDataDirectory nDimForGrasp nNeighbors nDimNeighbors scratchDataDirectory directoryName = [syntheticDataDirectory '/' typeData '/'] nFiles = length(dir([directoryName 'graspPriorityWidth_' typeData '*.png'])) nearDist = 0; farDist = 1.2; segSize = (farDist - nearDist) / 3; segments = nearDist + [0 segSize 2*segSize 3*segSize]; for pic = 0:0;%(nFiles-1) A = (imread([directoryName typeData sprintf('%04d', pic) '.png'], 'png')); points = load([directoryName 'xyz_points' sprintf('%02d', pic) '.txt']); depthImage = zeros(size(A, 1), size(A, 2), 3); depthVector = [points(:, 1:2) (sqrt((points(:, 3:5).^2) * ones(3,1)))]; depthSegments = points(:, 1:2); for seg = 1:(length(segments)-1) greaterThanThisVal = segments(seg); inThisSeg = (depthVector(:, 3) > segments(seg)) & (depthVector(:, 3) <= segments(seg+1)); beyondThisSeg = (depthVector(:, 3) > segments(seg+1)); renormedSegment = (inThisSeg .* (depthVector(:, 3) - segments(seg)) / segSize) + beyondThisSeg; depthSegments = [depthSegments renormedSegment]; end for pointsRow = 1:(size(depthSegments, 1)) depthImage(depthSegments(pointsRow, 1), depthSegments(pointsRow, 2), 1:3) = depthSegments(pointsRow, 3:5); end imwrite(depthImage, [directoryName 'depth_' typeData sprintf('%04d', pic) '.png'], 'png'); end