forked from ivalab/grasp_multiObject
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rgbd2rgd.m
31 lines (22 loc) · 822 Bytes
/
rgbd2rgd.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
imgDataDir = ['rgbd'];
imgDataOutDir = ['rgd'];
imgFiles = dir([imgDataDir '/rgb*']);
imgDepthFiles = dir([imgDataDir '/depth*']);
for idx = 1:length(imgFiles)
display(['processing imgFiles ' int2str(idx)])
% read rgb
imgName = imgFiles(idx).name;
[pathstr,imgname] = fileparts(imgName);
rgb = imread([imgDataDir '/' imgname '.jpg']);
% read depth
imgDepthName = imgDepthFiles(idx).name;
[pathstr,imgdepthname] = fileparts(imgDepthName);
depth = imread([imgDataDir '/' imgdepthname '.png']);
% re-ragne to 0~225
depth = (double(depth)-500)/(1200-500)*255;
depthImgUint = uint8(depth);
% insert depth to th 3rd channel
rgb(:,:,3) = depthImgUint;
% saving rgd
imwrite(rgb, [imgDataOutDir '/rgd' imgname(end-4:end) '.png']);
end