0
$\begingroup$

I am curious about how depth maps work. While searching I came across this website which contains some images and their depth maps. I took this depth map and tried to study it using a python pillow.

enter image description here

from PIL import Image
import numpy as np

image = Image.open('elephant_depth_s.png')
img = np.asarray(image)

print(img.shape)

The depth map shape is (400, 400, 3) with 3 channels. Contrary to my assumption this depth map has three channels instead of one. Even though most of the values are zeros some are not. This len(np.where(img>0)) shows that all the channels have some values greater than zero. My question is;

  • In color images, RGB channel values are used for creating corresponding color pixels. Example RGB (255,255,0) creates yellow.

In this depth map how these three channel corresponds to the depth?

Can you please give us some more information on depth maps and their real-world applications?

$\endgroup$
1
$\begingroup$

Depth maps are created using principles of photometry (method of measuring light).

The depth maps (rather images) you took from the website are "images" not exact depth "maps". So by default when you pull out a png image from a webpage, it will be saved in "RGB". That is the reason you got an array with 3 layers. In practice, it will always be a single layer that simply shows relative brightness at each point.

The webpage you referred to is talking about "ray tracing" using software called PoVRay (Persistence of Vision Ray Tracing). What it does is creates a 3D surface with a source of light at a point in the frame and simply measures the intensity of light falling on the surface. Remember this is 3D. When you capture this surface from a point using a camera you get a 2D image that represents a "depth map" as seen from a point of reference with respect to the source of light.

A depth map has plenty of applications in computer vision, photography, and ray tracing. Illuminating a frame, measuring depth are few such applications.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.