Skip to content

module api.transforms.random


function RandomIntegers

RandomIntegers(
    low=0,
    high=None,
    size=None,
    dtype=<class 'numpy.int64'>,
    endpoint=False,
    tolist=False,
    rng=Generator(PCG64) at 0x7FF1ECC473C0
)

function RandomFloats

RandomFloats(
    low=0.0,
    high=1.0,
    size=None,
    dtype=<class 'numpy.float64'>,
    tolist=False,
    rng=Generator(PCG64) at 0x7FF1ECC473C0
)

function RandomProbabilities

RandomProbabilities(
    size=None,
    dtype=<class 'numpy.float64'>,
    rng=Generator(PCG64) at 0x7FF1ECC473C0
)

function RandomChoice

RandomChoice(
    candidates: List = None,
    return_index=False,
    rng=Generator(PCG64) at 0x7FF1ECC473C0
)

function RandomROI

RandomROI(
    img=None,
    img_w: int = None,
    img_h: int = None,
    roi_h: int,
    roi_w: int,
    rng=Generator(PCG64) at 0x7FF1ECC473C0
)

generate random region of interest.

Args:

  • roi_h (int): roi height.

  • roi_w (int): roi width.

  • img (np.ndarray, optional): if img_w or img_h is not specified, infer from img. Defaults to None.

  • img_w (int, optional): source image width. Defaults to None.

  • img_h (int, optional): source image height. Defaults to None. rng (np.random.Generator, optional).

Returns:

  • Tuple[int]: (top, bottom, left, right)

function RandomDo

RandomDo(
    translist: List[Callable],
    prob: float = 0.5,
    rng=Generator(PCG64) at 0x7FF1ECC473C0
)

function RandomImage

RandomImage(
    img_w=640,
    img_h=480,
    color=True,
    low=0,
    high=255,
    dtype=<class 'numpy.uint8'>,
    rng=Generator(PCG64) at 0x7FF1ECC473C0
)

generate a random image for testing purpose

Args:

  • img_w (int, optional): generated image width. Defaults to 640.

  • img_h (int, optional): generated image height. Defaults to 480.

  • color (bool, optional): if True, return (H, W, 3) else (H, W)-sized iamge. Defaults to True.

  • low (int, optional): minimum pixel value. Defaults to 0.

  • high (int, optional): maximum pixel value. Defaults to 255.

  • dtype (optional): Defaults to np.uint8.

  • rng (optional): np.random.Generator. Defaults to _rng.

Returns:

  • np.ndarray: image array (H, W) or (H, W, 3)