blenderproc.postprocessing package

Module contents

blenderproc.postprocessing.add_gaussian_shifts(image, std=0.5)

Randomly shifts the pixels of the input depth image in x and y direction.

Parameters:
  • image (Union[list, ndarray]) – Input depth image(s)

  • std (float) – Standard deviation of pixel shifts, defaults to 0.5

Return type:

Union[list, ndarray]

Returns:

Augmented images

blenderproc.postprocessing.add_kinect_azure_noise(depth, color=None, missing_depth_darkness_thres=15)

Add noise, holes and smooth depth maps according to the noise characteristics of the Kinect Azure sensor. https://www.mdpi.com/1424-8220/21/2/413

For further realism, consider to use the projection from depth to color image in the Azure Kinect SDK: https://docs.microsoft.com/de-de/azure/kinect-dk/use-image-transformation

Parameters:
  • depth (Union[list, ndarray]) – Input depth image(s) in meters

  • color (Union[list, ndarray, None]) – Optional color image(s) to add missing depth at close to black surfaces

  • missing_depth_darkness_thres (int) – uint8 gray value threshold at which depth becomes invalid, i.e. 0

Return type:

Union[list, ndarray]

Returns:

Noisy depth image(s)

blenderproc.postprocessing.apply_lens_distortion(image, mapping_coords=None, orig_res_x=None, orig_res_y=None, use_interpolation=True)

This functions applies the lens distortion mapping that needs to be precalculated by bproc.camera.set_lens_distortion().

Without calling this function the set_lens_distortion fct. only increases the image resolution and changes the K matrix of the camera.

Parameters:
  • image (Union[List[ndarray], ndarray]) – a list of images or an image to be distorted

  • mapping_coords (Optional[ndarray]) – an array of pixel mappings from undistorted to distorted image

  • orig_res_x (Optional[int]) – original and output width resolution of the image

  • orig_res_y (Optional[int]) – original and output height resolution of the image

  • use_interpolation (bool) – if this is True, for each pixel an interpolation will be performed, if this is false the nearest pixel will be used

Return type:

Union[List[ndarray], ndarray]

Returns:

a list of images or an image that have been distorted, now in the desired (original) resolution

blenderproc.postprocessing.depth2dist(depth)

Maps a depth image to distance image, also works with a list of images.

Parameters:

depth (Union[List[ndarray], ndarray]) – The depth data.

Return type:

Union[List[ndarray], ndarray]

Returns:

The distance data

blenderproc.postprocessing.dist2depth(dist)

Maps a distance image to depth image, also works with a list of images.

Parameters:

dist (Union[List[ndarray], ndarray]) – The distance data.

Return type:

Union[List[ndarray], ndarray]

Returns:

The depth data

blenderproc.postprocessing.oil_paint_filter(image, filter_size=5, edges_only=True, rgb=False)

Applies the oil paint filter on a single channel image (or more than one channel, where each channel is a replica of the other). This could be desired for corrupting rendered depth maps to appear more realistic. Also trims the redundant channels if they exist.

Parameters:
  • image (Union[list, ndarray]) – Input image or list of images

  • filter_size (int) – Filter size, should be an odd number.

  • edges_only (bool) – If true, applies the filter on the edges only.

  • rgb (bool) – Apply the filter on an RGB image (if the image has 3 channels, they’re assumed to not be replicated).

Return type:

Union[list, ndarray]

Returns:

filtered image

blenderproc.postprocessing.remove_segmap_noise(image)

A function that takes an image and a few 2D indices, where these indices correspond to pixel values in segmentation maps, where these values are not real labels, but some deviations from the real labels, that were generated as a result of Blender doing some interpolation, smoothing, or other numerical operations.

Assumes that noise pixel values won’t occur more than 100 times.

Parameters:

image (Union[list, ndarray]) – ndarray of the .exr segmap

Return type:

Union[list, ndarray]

Returns:

The denoised segmap image

blenderproc.postprocessing.stereo_global_matching(color_images, depth_max=None, window_size=7, num_disparities=32, min_disparity=0, disparity_filter=True, depth_completion=True)

Does the stereo global matching in the following steps: 1. Collect camera object and its state, 2. For each frame, load left and right images and call the sgm() methode. 3. Write the results to a numpy file.

Parameters:
  • color_images (List[ndarray]) – A list of stereo images, where each entry has the shape [2, height, width, 3].

  • depth_max (Optional[float]) – The maximum depth value for clipping the resulting depth values. If None, distance_start + distance_range that were configured for distance rendering are used.

  • window_size (int) – Semi-global matching kernel size. Should be an odd number.

  • num_disparities (int) – Semi-global matching number of disparities. Should be > 0 and divisible by 16.

  • min_disparity (int) – Semi-global matching minimum disparity.

  • disparity_filter (bool) – Applies post-processing of the generated disparity map using WLS filter.

  • depth_completion (bool) – Applies basic depth completion using image processing techniques.

Return type:

Tuple[List[ndarray], List[ndarray]]

Returns:

Returns the computed depth and disparity images for all given frames.

blenderproc.postprocessing.trim_redundant_channels(image)

Remove redundant channels, this is useful to remove the two of the three channels created for a depth or distance image. This also works on a list of images. Be aware that there is no check performed, to ensure that all channels are really equal.

Parameters:

image (Union[list, ndarray]) – Input image or list of images

Return type:

Union[list, ndarray]

Returns:

The trimmed image data with preserved input type