Crop#

class pyrost.Crop(roi)#

Crop transform. Crops a frame according to a region of interest.

Parameters

roi (Union[List[int], Tuple[int, int, int, int], ndarray]) – Region of interest. Comprised of four elements [y_min, y_max, x_min, x_max].

backward_points(x, y)#

Transform detector coordinates back.

Parameters
  • x (ndarray) – A set of transformed x coordinates.

  • y (ndarray) – A set of transformed y coordinates.

Return type

Tuple[ndarray, ndarray]

Returns

A tuple of x and y coordinates.

contents()#

Return a list of the attributes stored in the container that are initialised.

Return type

List[str]

Returns

List of the attributes stored in the container.

forward(inp)#

Return a transformed image.

Parameters

inp (ndarray) – Input image.

Return type

ndarray

Returns

Transformed image.

forward_points(x, y)#

Transform detector coordinates.

Parameters
  • x (ndarray) – A set of x coordinates.

  • y (ndarray) – A set of y coordinates.

Return type

Tuple[ndarray, ndarray]

Returns

A tuple of transformed x and y coordinates.

get(attr, value=None)#

Retrieve a dataset, return value if the attribute is not found.

Parameters
  • attr (str) – Data attribute.

  • value (Optional[Any]) – Data which is returned if the attribute is not found.

Return type

Any

Returns

Attribute’s data stored in the container, value if attr is not found.

index_array(ss_idxs, fs_idxs)#

Filter the indices of a frame (ss_idxs, fs_idxs) according to the cropping transform.

Parameters
  • ss_idxs (ndarray) – Slow axis indices of a frame.

  • fs_idxs (ndarray) – Fast axis indices of a frame.

Return type

Tuple[ndarray, ndarray]

Returns

A tuple of filtered frame indices (ss_idxs, fs_idxs).

items()#

Return (key, value) pairs of the datasets stored in the container.

Return type

ItemsView

Returns

(key, value) pairs of the datasets stored in the container.

keys()#

Return a list of the attributes available in the container.

Return type

List[str]

Returns

List of the attributes available in the container.

replace(**kwargs)#

Return a new container object with a set of attributes replaced.

Parameters

kwargs (Any) – A set of attributes and the values to to replace.

Return type

~D

Returns

A new container object with updated attributes.

values()#

Return the attributes’ data stored in the container.

Return type

ValuesView

Returns

List of data stored in the container.