fabiotosi92 / NeRF-Supervised-Deep-Stereo

A novel paradigm for collecting and generating stereo training data using neural rendering
https://nerfstereo.github.io/
MIT License
348 stars 19 forks source link

Some questions about disparity maps. #28

Closed guwenxiang1 closed 1 year ago

guwenxiang1 commented 1 year ago

I downloaded a portion of the dataset, specifically v1_part1, and I used the following code to read the disparity maps from it. transform = transforms.ToTensor()

for file in depth_files: if file.endswith('.png'): depth_image = Image.open(os.path.join(depth_folder, file)) depth_image = transform(depth_image).squeeze().to(device) print(depth_image.shape) print(depth_image.max(), depth_image.min())

Some print results are: torch.Size([522, 1160]) tensor(16301, dtype=torch.int32) tensor(1907, dtype=torch.int32) torch.Size([522, 1160]) tensor(9634, dtype=torch.int32) tensor(2407, dtype=torch.int32) torch.Size([522, 1160]) tensor(11203, dtype=torch.int32) tensor(2654, dtype=torch.int32) The disparity values stored in PNG files range from over 1000 to over 10000, and I am confused about such values. Aren't the values in PNG supposed to be within the range of 0-255 or 0-1? Also, are these values representing disparity? Why are they so large?

mattpoggi commented 1 year ago

Hi, because they are 16 bit images. Please check the README file:

"The disparity maps and AO maps are saved as 16-bit images. To obtain the actual disparity values, please divide the disparity map values by a factor of 64. Similarly, divide the AO map values by a factor of 65536. "

You can find an example in code_snippets/dataloader.py at line 159.