RgbaToRgb#
Remove the alpha (last) channel from an RGBA image
Input Format - (height, width, 4): RGBA image
Output Format - (height, width, 3): RGB image
Example
import asyncio import omni.replicator.core as rep async def test_rgba_to_rgb(): rp = rep.create.render_product(rep.create.camera(), (640, 480)) augmented_anno = rep.annotators.get("LdrColor", device="cuda").augment("RgbaToRgb") augmented_anno.attach(rp) await rep.orchestrator.step_async() data = augmented_anno.get_data() print(data.shape) # (480, 640, 4) asyncio.ensure_future(test_rgba_to_rgb())
ColorizeDepth#
Colorize depth data.
Distance to camera is inverted and normalized to the range [0, 255] in greyscale RGB.
Input Format - (height, width): Depth data
Output Format - (height, width, 3): RGB image
Example
import asyncio import omni.replicator.core as rep async def test_colorize_depth(): rp = rep.create.render_product(rep.create.camera(), (640, 480)) augmented_anno = rep.annotators.get("distance_to_camera", device="cuda").augment( "ColorizeDepth", ) augmented_anno.attach(rp) await rep.orchestrator.step_async() data = augmented_anno.get_data() print(data.shape) # (480, 640, 3) asyncio.ensure_future(test_colorize_depth())
ColorizeNormals#
Colorize normal data.
Input Format - (height, width, 3): Normal data
Output Format - (height, width, 3): RGB image
Example
import asyncio import omni.replicator.core as rep async def test_colorize_normals(): rp = rep.create.render_product(rep.create.camera(), (640, 480)) augmented_anno = rep.annotators.get("normals", device="cuda").augment("ColorizeNormals") augmented_anno.attach(rp) await rep.orchestrator.step_async() data = augmented_anno.get_data() print(data.shape) # (480, 640, 3) asyncio.ensure_future(test_colorize_normals())
Sobel#
Apply Sobel edge detection to an image.
Input Format - (height, width, 4): RGBA image
Output Format - (height, width, 4): RGBA image with detected edges
Example
import asyncio import omni.replicator.core as rep async def test_sobel_edges(): rp = rep.create.render_product(rep.create.camera(), (640, 480)) augmented_anno = rep.annotators.get("LdrColor", device="cuda").augment("Sobel") augmented_anno.attach(rp) await rep.orchestrator.step_async() data = augmented_anno.get_data() print(data.shape) # (480, 640, 4) asyncio.ensure_future(test_sobel_edges())
AdjustSigmoid#
Perform sigmoid correction on an image
A form of contrast adjustment, transforms each pixel (normalized to be between 0 and 1) of an image according to the equation \(Out = ({1 + e^{gain \cdot (cutoff - In)}})^{-1}\) [1] [2].
Initialization Parameters
cutoff (float): Shifts the characteristic sigmoid curve horizontally
gain (float): Multiplier in the exponent’s power of sigmoid function.
Input Format - (height, width, 4): RGBA image
Output Format - (height, width, 4): RGBA image
Example
import asyncio import omni.replicator.core as rep async def test_adjust_sigmoid(): rp = rep.create.render_product(rep.create.camera(), (640, 480)) augmented_anno = rep.annotators.get("LdrColor", device="cuda").augment( "AdjustSigmoid", cutoff=0.2, gain=20.0 ) augmented_anno.attach(rp) await rep.orchestrator.step_async() data = augmented_anno.get_data() print(data.shape) # (480, 640, 4) asyncio.ensure_future(test_adjust_sigmoid())References
Brightness#
Modify the brightness of an image.
Initialization Parameters
brightness_factor (float): value between
[-100, 100]that determines the brightness modification.Input Format - (height, width, 4): RGBA image
Output Format - (height, width, 4): RGBA image
Example
import asyncio import omni.replicator.core as rep async def test_brightness(): rp = rep.create.render_product(rep.create.camera(), (640, 480)) augmented_anno = rep.annotators.get("LdrColor", device="cuda").augment( "Brightness", brightness_factor=5.0 ) augmented_anno.attach(rp) await rep.orchestrator.step_async() data = augmented_anno.get_data() print(data.shape) # (480, 640, 4) asyncio.ensure_future(test_brightness())
SpeckleNoise#
Add speckle noise to an RGBA image
Provided a noise scaling factor
sigma, add speckle noise to each pixel of the image.Initialization Parameters
sigma (float): determines the amount of noise to add. A larger value produces a noisier image.
seed (int): Seed to use as initialization for the pseudo-random number generator. Seed is expected to be a non-negative integer.
Input Format - (height, width, 4): RGBA image
Output Format - (height, width, 4): RGBA image
Example
import asyncio import omni.replicator.core as rep async def test_speckle_noise(): rp = rep.create.render_product(rep.create.camera(), (640, 480)) augmented_anno = rep.annotators.get( "LdrColor", device="cuda" ).augment("SpeckleNoise", sigma=0.2) augmented_anno.attach(rp) await rep.orchestrator.step_async() data = augmented_anno.get_data() print(data.shape) # (480, 640, 4) asyncio.ensure_future(test_speckle_noise())
ShotNoise#
Add shot noise to an RGBA image
Provided a noise scaling factor
sigma, add shot noise to each pixel of the image.Initialization Parameters
sigma (float): Determines the amount of noise to add. A larger value produces a noisier image.
seed (int): Seed to use as initialization for the pseudo-random number generator. Seed is expected to be a non-negative integer.
Input Format - (height, width, 4): RGBA image
Output Format - (height, width, 4): RGBA image
Example
import asyncio import omni.replicator.core as rep async def test_shot_noise(): rp = rep.create.render_product(rep.create.camera(), (640, 480)) augmented_anno = rep.annotators.get("LdrColor", device="cuda").augment("ShotNoise", sigma=0.2) augmented_anno.attach(rp) await rep.orchestrator.step_async() data = augmented_anno.get_data() print(data.shape) # (480, 640, 4) asyncio.ensure_future(test_shot_noise())
RgbToHsv#
Modifies an RGB image to HSV
Input Format - (height, width, 4): RGBA image
Output Format - (height, width, 4): RGBA image
Example
import asyncio import omni.replicator.core as rep async def test_rgb_to_hsv(): rp = rep.create.render_product(rep.create.camera(), (640, 480)) augmented_anno = rep.annotators.get("LdrColor", device="cuda").augment("HsvToRgb") augmented_anno.attach(rp) await rep.orchestrator.step_async() data = augmented_anno.get_data() print(data.shape) # (480, 640, 4) asyncio.ensure_future(test_rgb_to_hsv())
HsvToRgb#
Modifies an HSV image to RGB
Input Format - (height, width, 4): RGBA image
Output Format - (height, width, 4): RGBA image
Example
import asyncio import omni.replicator.core as rep async def test_hsv_to_rgb(): rp = rep.create.render_product(rep.create.camera(), (640, 480)) augmented_anno = rep.annotators.get("LdrColor", device="cuda").augment_compose( ["RgbToHsv", "HsvToRgb"] ) augmented_anno.attach(rp) await rep.orchestrator.step_async() data = augmented_anno.get_data() print(data.shape) # (480, 640, 4) asyncio.ensure_future(test_hsv_to_rgb())
GlassBlur#
Applies a Glass Blur augmentation to an RGBA image.
To simulate glass blur, each pixel is swapped with another sampled from within a window whose size is determined by the
deltaparameter.Initialization Parameters
delta (int): determines the maximum window size from which to sample a pixel. A larger value produces a blurrier effect.
seed (int): Seed to use as initialization for the pseudo-random number generator. Seed is expected to be a non-negative integer.
Input Format - (height, width, 4): RGBA image
Output Format - (height, width, 4): RGBA image
Example
import asyncio import omni.replicator.core as rep async def test_glass_blur(): rp = rep.create.render_product(rep.create.camera(), (640, 480)) augmented_anno = rep.annotators.get("LdrColor", device="cuda").augment("GlassBlur", delta=5) augmented_anno.attach(rp) await rep.orchestrator.step_async() data = augmented_anno.get_data() print(data.shape) # (480, 640, 4) asyncio.ensure_future(test_glass_blur())
BackgroundRand#
Randomize and apply a background image.
Given a folder path, valid images are randomly selected and applied as the background to the current image.
Initialization Parameters
folderpath (str): Path to directory containing images to be used as backgrounds.
seed (int): Seed to use as initialization for the pseudo-random number generator for the sampler controlling image selection. Seed is expected to be a non-negative integer.
Input Format - (height, width, 4): RGBA image
Output Format - (height, width, 4): RGBA image
Example
import asyncio import omni.replicator.core as rep async def test_background_rand(): rp = rep.create.render_product(rep.create.camera(), (640, 480)) augmented_anno = rep.annotators.get("LdrColor", device="cuda").augment( "BackgroundRand", folderpath=rep.example.TEXTURES_DIR ) augmented_anno.attach(rp) await rep.orchestrator.step_async() data = augmented_anno.get_data() print(data["data"].shape) # (480, 640, 4) print(data["info"]) # {'xform': array([1., 0., 0., 0., 1., 0., 0., 0., 1.])} asyncio.ensure_future(test_background_rand())
Contrast#
Adjust the contrast of an image.
Initialization Parameters
contrastFactor (float): Positive float value specifying how much to adjust the contrast. A value of
0.0produces a solid grey image,1.0results in the original input image and2.0increases the contrast by a factor of2.0.Input Format - (height, width, 4): RGBA image
Output Format - (height, width, 4): RGBA image
Example
import asyncio import omni.replicator.core as rep async def test_adjust_contrast(): rp = rep.create.render_product(rep.create.camera(), (640, 480)) augmented_anno = rep.annotators.get("LdrColor", device="cuda").augment( "Contrast", contrastFactor=1.5 ) augmented_anno.attach(rp) await rep.orchestrator.step_async() data = augmented_anno.get_data() print(data["data"].shape) # (480, 640, 4) print(data["info"]) # {'xform': array([1., 0., 0., 0., 1., 0., 0., 0., 1.])} asyncio.ensure_future(test_adjust_contrast())
Conv2d#
Apply a 2D convolution to an image
Initialization Parameters
kernel (float[]): The kernel to convolve with an image. Kernel is provided as a flattened array of size
[N * N]whereNis the kernel size.Input Format - (height, width, 4): RGBA image
Output Format - (height, width, 4): RGBA image
Example
import asyncio import numpy as np import omni.replicator.core as rep async def test_conv2d(): rp = rep.create.render_product(rep.create.camera(), (640, 480)) # Create a gaussian blur kernel gaussian_blur = np.array([ [0.0625, 0.1250, 0.0625], [0.1250, 0.2500, 0.1250], [0.0625, 0.1250, 0.0625], ]) augmented_anno = rep.annotators.get("LdrColor", device="cuda").augment( "Conv2d", kernel=gaussian_blur ) augmented_anno.attach(rp) await rep.orchestrator.step_async() data = augmented_anno.get_data() print(data["data"].shape) # (480, 640, 4) print(data["info"]) # {'xform': array([1., 0., 0., 0., 1., 0., 0., 0., 1.])} asyncio.ensure_future(test_conv2d())
CropResize#
Crop, resize and translate an image.
Initialization Parameters
cropFactor (float): Value between >0.0 and 1.0 specifying the amount of the image to crop. A value of
1.0indicates no crop and a value of 0.5 will crop the image by half.offsetFactor (float[2]): Value between (-1.0 and 1.0) indicating the translation offset factor in
(vertical, horizontal)directions. A value of(-1.0, -1.0)will translate the cropped image to the bottom-most and left-most, and a value of(1.0, 1.0)to the top-most and right-most. Note that ifcropFactoris set to1.0, no translation is possible.seed (int): Seed to use as initialization for the pseudo-random number generator for the sampler controlling image selection. Seed is expected to be a non-negative integer.
Input Format - (height, width, 4): RGBA image
Output Format - (height, width, 4): RGBA image
Example
import asyncio import omni.replicator.core as rep async def test_crop_resize(): rp = rep.create.render_product(rep.create.camera(), (640, 480)) augmented_anno = rep.annotators.get("LdrColor", device="cuda").augment( "CropResize", cropFactor=0.5, offset_factor=(-0.2, 0.2) ) augmented_anno.attach(rp) await rep.orchestrator.step_async() data = augmented_anno.get_data() print(data["data"].shape) # (480, 640, 4) print(data["info"]) # {'xform': array([ 2., 0., 320., 0., 2., -720., 0., 0., 1.])} asyncio.ensure_future(test_crop_resize())
CutMix#
Randomly apply a rectangular patch from another image onto the input image.
The augmentation takes in a random rectangular patch from another image and superimposes it on the input image. The rectangular patch is encoded in a binary mask where the pixels belonging to the rectangle have a mask value of 1 and 0 otherwise.
Initialization Parameters
folderpath (str): Path to directory containing images to be used as patches.
seed (int): Seed to use as initialization for the pseudo-random number generator for the sampler controlling image selection. Seed is expected to be a non-negative integer.
Input Format - (height, width, 4): RGBA image
Output Format - (height, width, 4): RGBA image
Example
import asyncio import omni.replicator.core as rep async def test_cut_mix(): rp = rep.create.render_product(rep.create.camera(), (640, 480)) augmented_anno = rep.annotators.get("LdrColor", device="cuda").augment( "CutMix", folderpath=rep.example.TEXTURES_DIR ) augmented_anno.attach(rp) await rep.orchestrator.step_async() data = augmented_anno.get_data() print(data["data"].shape) # (480, 640, 4) print(data["info"]) # {'xform': array([1., 0., 0., 0., 1., 0., 0., 0., 1.])} asyncio.ensure_future(test_cut_mix())
ImageBlend#
Blend an input image with a sampled blend image.
Initialization Parameters
blendFactor (float): Blend amount. A value of
0.0will return the original image and a value of1.0will return the blend image.folderpath (str): Path to directory containing images to be used as patches.
seed (int): Seed to use as initialization for the pseudo-random number generator for the sampler controlling image selection. Seed is expected to be a non-negative integer.
Input Format - (height, width, 4): RGBA image
Output Format - (height, width, 4): RGBA image
Example
import asyncio import omni.replicator.core as rep async def test_image_blend(): rp = rep.create.render_product(rep.create.camera(), (640, 480)) augmented_anno = rep.annotators.get("LdrColor", device="cuda").augment( "ImageBlend", blendFactor=0.2, folderpath=rep.example.TEXTURES_DIR ) augmented_anno.attach(rp) await rep.orchestrator.step_async() data = augmented_anno.get_data() print(data["data"].shape) # (480, 640, 4) print(data["info"]) # {'xform': array([1., 0., 0., 0., 1., 0., 0., 0., 1.])} asyncio.ensure_future(test_image_blend())
MotionBlur#
Apply a motion blur effect to an input image.
Initialization Parameters
motionAngle (float): Angle in degrees where
0indicates motion towards the left,90towards the bottom, and270towards the top.strength (float): Motion Blur strength from
-1to1.kernelSize (int): Size of the conv kernel which controls the size of blur that will be produced.
Input Format - (height, width, 4): RGBA image
Output Format - (height, width, 4): RGBA image
Example
import asyncio import omni.replicator.core as rep async def test_motion_blur(): rp = rep.create.render_product(rep.create.camera(), (640, 480)) augmented_anno = rep.annotators.get("LdrColor", device="cuda").augment( "MotionBlur", motionAngle=45.0, strength=0.8, kernelSize=25 ) augmented_anno.attach(rp) await rep.orchestrator.step_async() data = augmented_anno.get_data() print(data["data"].shape) # (480, 640, 4) print(data["info"]) # {'xform': array([1., 0., 0., 0., 1., 0., 0., 0., 1.])} asyncio.ensure_future(test_motion_blur())
Pixellate#
Pixellate an input image.
Initialization Parameters
kernelSize (int): Size of the conv kernel which controls how many original pixels get consolidated into a single larger pixel.
Input Format - (height, width, 4): RGBA image
Output Format - (height, width, 4): RGBA image
Example
import asyncio import omni.replicator.core as rep async def test_pixellate(): rp = rep.create.render_product(rep.create.camera(), (640, 480)) augmented_anno = rep.annotators.get("LdrColor", device="cuda").augment( "Pixellate", kernelSize=25 ) augmented_anno.attach(rp) await rep.orchestrator.step_async() data = augmented_anno.get_data() print(data["data"].shape) # (480, 640, 4) print(data["info"]) # {'xform': array([1., 0., 0., 0., 1., 0., 0., 0., 1.])} asyncio.ensure_future(test_pixellate())
Rotate#
Rotate an input image.
Initialization Parameters
rotation (float): Clockwise image rotation in degrees. A value of
0.0corresponds to no rotation.Input Format - (height, width, 4): RGBA image
Output Format - (height, width, 4): RGBA image
Example
import asyncio import omni.replicator.core as rep async def test_rotate(): camera = rep.create.camera() rp = rep.create.render_product(camera, (640, 480)) augmented_anno = rep.annotators.get("LdrColor", device="cuda").augment("Rotate", rotation=90) augmented_anno.attach(rp) await rep.orchestrator.step_async() data = augmented_anno.get_data() print(data["data"].shape) # (480, 640, 4) print(data["info"]) # {'xform': array([ 0.0, 1.0, 80.0, -1.0, 0.0, 559.0, 0.0, 0.0, 1.0])} # Test bounding box transform based on rotation xform # Add a labelled sphere with rep.create.sphere(semantics=[("class", "sphere")]): rep.modify.pose_camera_relative( camera=camera, render_product=rp, distance=700, horizontal_location=0.2, vertical_location=0.4 ) # Add a labelled cone with rep.create.cone(semantics=[("class", "cone")]): rep.modify.pose_camera_relative( camera=camera, render_product=rp, distance=500, horizontal_location=-0.2, vertical_location=0.1, ) # Add bounding box annotator bbox_2d = rep.annotators.get("bounding_box_2d_tight_fast") bbox_2d.attach(rp) await rep.orchestrator.step_async() data = augmented_anno.get_data() xform = data["info"]["xform"] bbox_data = bbox_2d.get_data()["data"] visualization = rep.tools.colorize_bbox_2d( data["data"].numpy(), bbox_data, xform, draw_rotated_boxes=True, ) from PIL import Image Image.fromarray(visualization).save("rotated_bbox.png") asyncio.ensure_future(test_rotate())
Canny#
Apply the Canny edge detection algorithm to an input image.
Initialization Parameters * thresholdLow (float): Low threshold for the hysteresis procedure. * thresholdHigh (float): High threshold for the hysteresis procedure.
Input Format - (height, width, 4): RGBA image
Output Format - (height, width, 4): RGBA image with detected edges
Example
import asyncio import omni.replicator.core as rep async def test_canny(): rp = rep.create.render_product(rep.create.camera(), (640, 480)) augmented_anno = rep.annotators.get("LdrColor", device="cuda").augment( "Canny", thresholdLow=100, thresholdHigh=200 ) augmented_anno.attach(rp) await rep.orchestrator.step_async() data = augmented_anno.get_data() print(data["data"].shape) # (480, 640, 4) asyncio.ensure_future(test_canny())