I have a depth map image which was obtained using a kinect camera. In that image I have selected a region of size [400,400] and stored it as another image. Now, I would like to know how to resize this image into a size of [x,y] in python.
I have a depth map image which was obtained using a kinect camera. In that image I have selected a region of size [400,400] and stored it as another image. Now, I would like to know how to resize this image into a size of [x,y] in python.
Same as a normal image
import cv2
import matplotlib.pyplot as plt
image = cv2.imread(path_to_your_image) # Insert your image address here
resized = cv2.resize(image, (x, y), interpolation = cv2.INTER_NEAREST)
plt.imshow(resized)
plt.show()
I don't recommend to reduce resolution of depth map the same way like it is done for images. Imagine a scene with a small object 5 m before the wall:
The best approach is to use the Mode function. Divide the original depth map into windows. Each window will represent one pixel in the downsized map. For each of them calculate the most frequent depth value. You can use Python's statistics.mode() function.