MCPcopy Create free account
hub / github.com/CompVis/diff2flow / interpolate_nans

Function interpolate_nans

diff2flow/dataset/depth_preprocessing.py:29–39  ·  view source on GitHub ↗

Interpolate nans in a depth image by using the closest non-nan value.

(array, fill_values=1e-4)

Source from the content-addressed store, hash-verified

27
28
29def interpolate_nans(array, fill_values=1e-4):
30 """
31 Interpolate nans in a depth image by using the closest non-nan value.
32 """
33 nans = np.isnan(array)
34 if not nans.any():
35 return array
36 x = lambda z: z.nonzero()[0]
37 array[nans] = np.interp(x(nans), x(~nans), array[~nans], left=fill_values, right=fill_values)
38 assert not np.isnan(array).any(), "There are still nans in the array."
39 return array
40
41
42def calculate_valid_mask(depth, dataset_name):

Callers 1

preprocess_depthFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected