Revert normalized depth in [0, 1] back to metric depth in [0, `max_depth`].
(
normalized: torch.Tensor,
image_format="log_depth",
max_depth=50.0,
min_depth=0.01,
)
| 2078 | return normalized |
| 2079 | |
| 2080 | def revert_depth( |
| 2081 | normalized: torch.Tensor, |
| 2082 | image_format="log_depth", |
| 2083 | max_depth=50.0, |
| 2084 | min_depth=0.01, |
| 2085 | ) -> torch.Tensor: |
| 2086 | """ |
| 2087 | Revert normalized depth in [0, 1] back to metric depth in [0, `max_depth`]. |
| 2088 | """ |
| 2089 | |
| 2090 | if image_format == "log_depth": |
| 2091 | metric = torch.exp2(normalized * np.log2(max_depth + 1 + 0.0001)) - 1 - 0.0001 |
| 2092 | elif image_format == "inverse_depth": |
| 2093 | metric = min_depth / normalized.add(1e-8) |
| 2094 | elif image_format == "depth": |
| 2095 | metric = normalized.mul(max_depth) |
| 2096 | else: |
| 2097 | raise ValueError |
| 2098 | return metric * get_mask(metric) |
| 2099 | |
| 2100 | def denormalize(x): |
| 2101 | """Scale from [-1, +1] to [0, 1]""" |
nothing calls this directly
no test coverage detected