blenderproc.python.postprocessing.PostProcessingUtility module

class blenderproc.python.postprocessing.PostProcessingUtility.PostProcessingUtility[source]

Bases: object

static _determine_noisy_pixels(image)[source]
Parameters:image (ndarray) – The image data.
Return type:ndarray
Returns:a list of 2D indices that correspond to the noisy pixels. One criteria of finding these pixels is to use a histogram and find the pixels with frequencies lower than a threshold, e.g. 100.
static _get_pixel_neighbors(data, i, j)[source]

Returns the valid neighbor pixel indices of the given pixel.

Parameters:
  • data (ndarray) – The whole image data.
  • i (int) – The row index of the pixel
  • j (int) – The col index of the pixel.
Return type:

ndarray

Returns:

A list of neighbor point indices.

static _get_pixel_neighbors_stacked(img, filter_size=3, return_list=False)[source]

Stacks the neighbors of each pixel according to a square filter around each given pixel in the depth dimensions. The neighbors are represented by shifting the input image in all directions required to simulate the filter.

Parameters:
  • img (ndarray) – Input image. Type: blender object of type image.
  • filter_size (int) – Filter size. Type: int. Default: 5..
  • return_list (bool) – Instead of stacking in the output array, just return a list of the “neighbor” images along with the input image.
Return type:

Union[list, ndarray]

Returns:

Either a tensor with the “neighbor” images stacked in a separate additional dimension, or a list of images of the same shape as the input image, containing the shifted images (simulating the neighbors) and the input image.

static _isin(element, test_elements, assume_unique=False, invert=False)[source]

As np.isin is only available after v1.13 and blender is using 1.10.1 we have to implement it manually.

blenderproc.python.postprocessing.PostProcessingUtility.depth2dist(depth)[source]
Parameters:depth (Union[list, ndarray]) – The depth data.
Return type:Union[list, ndarray]
Returns:The distance data
blenderproc.python.postprocessing.PostProcessingUtility.dist2depth(dist)[source]
Parameters:dist (Union[list, ndarray]) – The distance data.
Return type:Union[list, ndarray]
Returns:The depth data
blenderproc.python.postprocessing.PostProcessingUtility.oil_paint_filter(image, filter_size=5, edges_only=True, rgb=False)[source]

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.python.postprocessing.PostProcessingUtility.remove_segmap_noise(image)[source]

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.python.postprocessing.PostProcessingUtility.trim_redundant_channels(image)[source]

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.