'How to get depth of an image after its been converted to cv2 image?

enter image description here

As a staring point, an image was created using cv2, this is a black-white image.

self.depth = .... #numpy array with x,y = depth 
cv2.imwrite(self.depth)  #saved as jpg

Later in my code I need to convert back to get values of depth.

image  = cv2.imread(path)
        self.depth_array = np.array(image, dtype=np.float32)

But in this array all values are between 0 or 255, while in self.depth array values were different, e.g. 10,3; 11,5; 18,5; etc. Is it possible tO convert back cv2 image to get [x,y] array with depth values?

P.S.

I've recently tried code provided under, but it still gives me 0.0 and 255.0 values:

cv2.imread(path, cv2.IMREAD_UNCHANGED)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source