@staticmethod<EOL><INDENT>def from_distance_maps(distance_maps, inverted=False, if_not_found_coords={"<STR_LIT:x>": -<NUM_LIT:1>, "<STR_LIT:y>": -<NUM_LIT:1>}, threshold=None, <EOL>nb_channels=None):<DEDENT>
ia.do_assert(len(distance_maps.shape) == <NUM_LIT:3>)<EOL>height, width, nb_keypoints = distance_maps.shape<EOL>drop_if_not_found = False<EOL>if if_not_found_coords is None:<EOL><INDENT>drop_if_not_found = True<EOL>if_not_found_x = -<NUM_LIT:1><EOL>if_not_found_y = -<NUM_LIT:1><EOL><DEDENT>elif isinstance(if_not_found_coords, (tuple, list)):<EOL><INDENT>ia.do_assert(len(if_not_found_coords) == <NUM_LIT:2>)<EOL>if_not_found_x = if_not_found_coords[<NUM_LIT:0>]<EOL>if_not_found_y = if_not_found_coords[<NUM_LIT:1>]<EOL><DEDENT>elif isinstance(if_not_found_coords, dict):<EOL><INDENT>if_not_found_x = if_not_found_coords["<STR_LIT:x>"]<EOL>if_not_found_y = if_not_found_coords["<STR_LIT:y>"]<EOL><DEDENT>else:<EOL><INDENT>raise Exception("<STR_LIT>" % (<EOL>type(if_not_found_coords),))<EOL><DEDENT>keypoints = []<EOL>for i in sm.xrange(nb_keypoints):<EOL><INDENT>if inverted:<EOL><INDENT>hitidx_flat = np.argmax(distance_maps[..., i])<EOL><DEDENT>else:<EOL><INDENT>hitidx_flat = np.argmin(distance_maps[..., i])<EOL><DEDENT>hitidx_ndim = np.unravel_index(hitidx_flat, (height, width))<EOL>if not inverted and threshold is not None:<EOL><INDENT>found = (distance_maps[hitidx_ndim[<NUM_LIT:0>], hitidx_ndim[<NUM_LIT:1>], i] < threshold)<EOL><DEDENT>elif inverted and threshold is not None:<EOL><INDENT>found = (distance_maps[hitidx_ndim[<NUM_LIT:0>], hitidx_ndim[<NUM_LIT:1>], i] >= threshold)<EOL><DEDENT>else:<EOL><INDENT>found = True<EOL><DEDENT>if found:<EOL><INDENT>keypoints.append(Keypoint(x=hitidx_ndim[<NUM_LIT:1>], y=hitidx_ndim[<NUM_LIT:0>]))<EOL><DEDENT>else:<EOL><INDENT>if drop_if_not_found:<EOL><INDENT>pass  <EOL><DEDENT>else:<EOL><INDENT>keypoints.append(Keypoint(x=if_not_found_x, y=if_not_found_y))<EOL><DEDENT><DEDENT><DEDENT>out_shape = (height, width)<EOL>if nb_channels is not None:<EOL><INDENT>out_shape += (nb_channels,)<EOL><DEDENT>return KeypointsOnImage(keypoints, shape=out_shape)<EOL>
Converts maps generated by ``to_distance_maps()`` back to a KeypointsOnImage object.

Parameters
----------
distance_maps : (H,W,N) ndarray
    The distance maps. N is the number of keypoints.

inverted : bool, optional
    Whether the given distance maps were generated in inverted or normal mode.

if_not_found_coords : tuple or list or dict or None, optional
    Coordinates to use for keypoints that cannot be found in ``distance_maps``.
    If this is a list/tuple, it must have two integer values.
    If it is a dictionary, it must have the keys ``x`` and ``y``, with each
    containing one integer value.
    If this is None, then the keypoint will not be added to the final
    KeypointsOnImage object.

threshold : float, optional
    The search for keypoints works by searching for the argmin (non-inverted) or
    argmax (inverted) in each channel. This parameters contains the maximum (non-inverted)
    or minimum (inverted) value to accept in order to view a hit as a keypoint.
    Use None to use no min/max.

nb_channels : None or int, optional
    Number of channels of the image on which the keypoints are placed.
    Some keypoint augmenters require that information.
    If set to None, the keypoint's shape will be set
    to ``(height, width)``, otherwise ``(height, width, nb_channels)``.

Returns
-------
imgaug.KeypointsOnImage
    The extracted keypoints.