blenderproc.postprocessing package¶
Module contents¶
-
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: Returns: a list of images or an image that have been distorted, now in the desired (original) resolution
- image (
-
blenderproc.postprocessing.
depth2dist
(depth)¶ Parameters: depth ( Union
[list
,ndarray
]) – The depth data.Return type: Union
[list
,ndarray
]Returns: The distance data
-
blenderproc.postprocessing.
dist2depth
(dist)¶ Parameters: dist ( Union
[list
,ndarray
]) – The distance data.Return type: Union
[list
,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: Returns: filtered image
- 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 segmapReturn 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: Returns: Returns the computed depth and disparity images for all given frames.
- color_images (
-
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 imagesReturn type: Union
[list
,ndarray
]Returns: The trimmed image data.