Skip to content

Use MATLAB to convert depth image into HHA image. In this repo, I will use NYU Depth V2 dataset as an example.

Notifications You must be signed in to change notification settings

charlesCXK/Depth2HHA

Repository files navigation

Depth2HHA

Introduction

First, I want to thank s-gupta for his excellent work. Actually, I got some inspiration from his code and fixed some problems in it.

This repo is used to convert Depth images into HHA images. HHA is an encoding method which extract the information in the depth image which was proposed in Learning Rich Features from RGB-D Images for Object Detection and Segmentation. In this repo, I use NYU Depth V2 dataset as an example.


All we need is:

  1. A depth image
  2. A raw-depth image


Usage

1. Modify main.m

depth_image_root = './depth'       % dir where depth images are in.
rawdepth_image_root = './rawdepth'       % dir where raw depth images are in.
hha_image_root = './hha'

saveHHA(['img_', mat2str(5000+i)], matrix, depth_image_root, D, RD);

depth_image_root is the directory of where depth images are in, and rawdepth_image_root is the directory of where raw depth images are in. The path of HHA can be defined by yourself by modifying parameters of saveHHA(imName, C, outDir, D, RD).

imName : name of HHA.

C : camera matrix

outDir : root of HHA images

D and RD : depth and raw-depth images. The raw-depth images are just used as masks, which you can understand from the corresponding code.

2. Modify saveHHA.m

Look at this line.

D = double(D)/1000;        % The unit of the element inside D is 'centimeter'

Here, D is the depth image. You may confused about the number '1000'. Because when I save the depth data as 'png', I multiply it with 1000. We all know that float number can not be saved as png or jpg, so I scale it. Anyway, after this line, the unit of the element in D should be 'meter'. It's up to you how to convert it.

3. Others

  • You can directly run main.m to use this repo.
  • You can use data that s-gupta supplies:
wget http://www.cs.berkeley.edu/~sgupta/eccv14/eccv14-data.tgz
tar -xf eccv14-data.tgz

Results

Pictures below are RGB, Depth, Raw-depth, HHA in turn.

About

Use MATLAB to convert depth image into HHA image. In this repo, I will use NYU Depth V2 dataset as an example.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages