montefiore-institute / midair-dataset

Example and utiliy scripts for the Mid-Air dataset
MIT License
15 stars 6 forks source link

About the disparity maps(16bit-1CH-PNG files) to real disparity. #4

Closed shawnfd closed 3 years ago

shawnfd commented 4 years ago

Thank you for creation of this amazing dataset to public, Micheal.

From the resources got from your website and git code till now, I haven't found a clear conversion coeficient from disparity map, which is 16bit png, to float disparity.

E.g., the sky's disparity in a disparity map(png file) is 8192, while I believe it should be 0.0-disparity, so obviously we developers need some extra SCALE&SHIFT conversion coeficients from map to real disparity.

Could you explain or provide us a new conversion script?

michael-fonder commented 3 years ago

Hi Shawn,

Sorry for the long delay... I'm just coming back from a long mission where we had an extremely limited internet access.

The disparity of the sky is not exactly equal to zero in our dataset. Due to simulator constraints, the sky is rendered as a sphere centred on the drone. This sphere has a radius of approximately 32km. As this not infinity, the corresponding disparity won't be exactly equal to zero, but will rather appear as a very small number (0.008 pixel for 32km). That's why you can't find true zeros in the disparity maps. It's up to you to decide if you want to round the small values to zero.

For the rest, the procedure to open the maps is the same than the one for depth maps. Basically, the binary data stored for each pixel correspond to a float16 number that directly gives the disparity in pixel. So there is not need for a scaling function. The only thing you need to do is to open the map with your favourite image library as a 16-bit image. As this will likely give you a 16-bit integer matrix, you'll need to find a way to bit-cast this matrix to the float16 type. We give an way to do this with numpy in the open_float16 function of this script: https://github.com/montefiore-ai/midair-dataset/blob/master/hdf5-depth_viewer.py

When I do this conversion for 8192, I get a float16 value of 0.007812 which is very close to the value I computed above.

Let me know if this helped or not!

shawnfd commented 3 years ago

Hi Shawn,

Sorry for the long delay... I'm just coming back from a long mission where we had an extremely limited internet access.

The disparity of the sky is not exactly equal to zero in our dataset. Due to simulator constraints, the sky is rendered as a sphere centred on the drone. This sphere has a radius of approximately 32km. As this not infinity, the corresponding disparity won't be exactly equal to zero, but will rather appear as a very small number (0.008 pixel for 32km). That's why you can't find true zeros in the disparity maps. It's up to you to decide if you want to round the small values to zero.

For the rest, the procedure to open the maps is the same than the one for depth maps. Basically, the binary data stored for each pixel correspond to a float16 number that directly gives the disparity in pixel. So there is not need for a scaling function. The only thing you need to do is to open the map with your favourite image library as a 16-bit image. As this will likely give you a 16-bit integer matrix, you'll need to find a way to bit-cast this matrix to the float16 type. We give an way to do this with numpy in the open_float16 function of this script: https://github.com/montefiore-ai/midair-dataset/blob/master/hdf5-depth_viewer.py

When I do this conversion for 8192, I get a float16 value of 0.007812 which is very close to the value I computed above.

Let me know if this helped or not!

Hi Shawn,

Sorry for the long delay... I'm just coming back from a long mission where we had an extremely limited internet access.

The disparity of the sky is not exactly equal to zero in our dataset. Due to simulator constraints, the sky is rendered as a sphere centred on the drone. This sphere has a radius of approximately 32km. As this not infinity, the corresponding disparity won't be exactly equal to zero, but will rather appear as a very small number (0.008 pixel for 32km). That's why you can't find true zeros in the disparity maps. It's up to you to decide if you want to round the small values to zero.

For the rest, the procedure to open the maps is the same than the one for depth maps. Basically, the binary data stored for each pixel correspond to a float16 number that directly gives the disparity in pixel. So there is not need for a scaling function. The only thing you need to do is to open the map with your favourite image library as a 16-bit image. As this will likely give you a 16-bit integer matrix, you'll need to find a way to bit-cast this matrix to the float16 type. We give an way to do this with numpy in the open_float16 function of this script: https://github.com/montefiore-ai/midair-dataset/blob/master/hdf5-depth_viewer.py

When I do this conversion for 8192, I get a float16 value of 0.007812 which is very close to the value I computed above.

Let me know if this helped or not!

Thank you so much, Michael! I followed your suggestion and it worked. After that I checked my own code reading the disparity map, it turns out that I mid-used some bit cast code when converting int16 to float16 format. By the way, really appreciate your dataset with so much diverse natural scene!