Live-wire

class pyift.livewire.LiveWire(image: numpy.ndarray, arc_fun: str = 'exp', saliency: Optional[numpy.ndarray] = None, **kwargs)[source]
__init__(image: numpy.ndarray, arc_fun: str = 'exp', saliency: Optional[numpy.ndarray] = None, **kwargs)[source]

Live-wire object to iteratively compute the optimum-paths 1 between user selected points.

Parameters
  • image (array_like) – Array where the first two dimensions are the image domain, the third and optional are its features.

  • arc_fun ({'exp'}, default='exp') – Optimum-path arc-weight function.

  • saliency (array_like, optional) – Array with the same dimension as the image domain containing the foreground saliency.

  • kwargs (float, optional) – Key word arguments for arc-weight function parameters.

arc_fun

Optimum-path arc-weight function.

Type

{‘exp’}, default=’exp’

image

Array where the first two dimensions are the image domain, the third and optional are its features.

Type

array_like

saliency

Array with additional features, usually object saliency. Must have the same domain as image.

Type

array_like, optional

costs

Array containing the optimum-path cost.

Type

array_like

preds

Array containing the predecessor map to recover the optimal contour.

Type

array_like

labels

Array indicating optimum-path nodes

Type

array_like

size

Tuple containing the image domain.

Type

tuple

sigma

Image features parameter.

Type

float

gamma

Saliency features parameter.

Type

float

source

Current path source node index (flattened array), -1 if inactive.

Type

int

destiny

Current path destiny node index (flattened array), -1 if inactive.

Type

int

start

Current contour starting node index, -1 if inactive.

Type

int

current

Active optimum-path, before confirmation.

Type

array_like

paths

Ordered dictionary of paths, key: path source, value: path sequence.

Type

dict

Examples

>>> import numpy as np
>>> from pyift.livewire import LiveWire
>>>
>>> image = np.array([[8, 1, 0, 2, 0],
>>>                   [5, 7, 2, 0, 1],
>>>                   [6, 7, 6, 1, 0],
>>>                   [6, 8, 7, 0, 3],
>>>                   [6, 7, 8, 8, 9]])
>>>
>>> lw = LiveWire(image, sigma=1.0)
>>> lw.select((0, 0))
>>> lw.confirm()
>>> lw.select((4, 4))
>>> lw.confirm()
>>> lw.contour

References

1

Falcão, Alexandre X., et al. “User-steered image segmentation paradigms: Live wire and live lane.” Graphical models and image processing 60.4 (1998): 233-260.

select(position: Union[Sequence[int], int]) → None[source]

Selects next position to compute optimum-path to, or initial position.

Parameters

position (Sequence[int, int], int) – Index or coordinate (y, x) in the image domain

cancel() → None[source]

Cancel current unconfirmed path.

confirm() → None[source]

Confirms current path and sets it as new path source.

close() → None[source]

Connects the current path to the initial coordinate, closing the live-wire contour. Result must be confirmed.

property contour

returns: Optimum-path contour. :rtype: array_like