Skip to content

XY Flip

Source

XY flip transform.

XYFlip

Bases: Transform

Flip image along X and Y axis, one at a time.

This transform randomly flips one of the last two axes.

This transform expects C(Z)YX dimensions.

Attributes:

  • axis_indices (List[int]) –

    Indices of the axes that can be flipped.

  • rng (Generator) –

    Random number generator.

  • p (float) –

    Probability of applying the transform.

  • seed (Optional[int]) –

    Random seed.

Parameters:

  • flip_x (bool, default: True ) –

    Whether to flip along the X axis, by default True.

  • flip_y (bool, default: True ) –

    Whether to flip along the Y axis, by default True.

  • p (float, default: 0.5 ) –

    Probability of applying the transform, by default 0.5.

  • seed (Optional[int], default: None ) –

    Random seed, by default None.

__call__(patch, target=None, **additional_arrays)

Apply the transform to the source patch and the target (optional).

Parameters:

  • patch (ndarray) –

    Patch, 2D or 3D, shape C(Z)YX.

  • target (Optional[ndarray], default: None ) –

    Target for the patch, by default None.

  • **additional_arrays (NDArray, default: {} ) –

    Additional arrays that will be transformed identically to patch and target.

Returns:

  • Tuple[ndarray, Optional[ndarray]]

    Transformed patch and target.

__init__(flip_x=True, flip_y=True, p=0.5, seed=None)

Constructor.

Parameters:

  • flip_x (bool, default: True ) –

    Whether to flip along the X axis, by default True.

  • flip_y (bool, default: True ) –

    Whether to flip along the Y axis, by default True.

  • p (float, default: 0.5 ) –

    Probability of applying the transform, by default 0.5.

  • seed (Optional[int], default: None ) –

    Random seed, by default None.