This repo implements HHA-encoding algorithm in python3. HHA image is an encoding algorithm to make better use of depth images, which was proposed by s-gupta in this paper: Learning Rich Features from RGB-D Images for Object Detection and Segmentation. This algorithm was implemented in MATLAB initially, and I organized a MATLAB version of the code: Depth2HHA-MATLAB. In this repo, I use python3 to get exactly the same result as what MATLAB code does.
All we need is:
If you are confused about depth images or you don't have depth images, please refer to NYU Depth V2 dataset.
I already provide an interface in getHHA.py. The function is named getHHA(C, D, RD). To be detailed, it needs a camera matrix C, a depth image D and a raw depth image RD. RD is used to generate a mask to mark missing information, so it is ok to use getHHA(C, D, D) if you don't have a raw depth image or you just want to do so.
D = cv2.imread(os.path.join(root, '0.png'), cv2.COLOR_BGR2GRAY)/10000
RD = cv2.imread(os.path.join(root, '0_raw.png'), cv2.COLOR_BGR2GRAY)/10000
camera_matrix = getCameraParam('color')
hha = getHHA(camera_matrix, D, RD)
Pictures below are visualizations of:
D:
RD:
HHA from MATLAB:
HHA using D and RD:
HHA using D and D:
If you find this project useful in your research, please consider cite:
@misc{Depth2HHA-python,
title={{Depth2HHA-python}: Converting depth maps to HHA encodings},
author={Xiaokang Chen},
howpublished = {\url{https://github.com/charlesCXK/Depth2HHA-python}},
year={2018}
}