SynthShapes.blending
Overview
The SynthShapes.blending module offers simple tools for combining multiple shapes, textures, or regions within an image to create seamless and realistic synthetic data. This module is ideal for applications that require simple to complex image compositions.
Blender
Bases: Module
An nn.Module for alpha blending ROIs of two tensors
within a specified ROI mask, and according to the blending parameter
alpha.
Diagram
flowchart TB
subgraph Inputs
foreground[Foreground Tensor]
background[Background Tensor]
mask[Mask: ROIs to blend]
end
foreground --standardize(μ=0, σ=1)--> standardized_foreground
mask --> masked_shifting
background --standardize(μ=0, σ=1)--> standardized_background
standardized_foreground --> masked_shifting
masked_shifting(Shift Foreground ROIs: add offset to masked
elements in standardized foreground) --> shifted_rois
shifted_rois["Shifted Foreground ROIs"] --> blender_function
standardized_background --> blender_function
blender_function("Blender Function: alpha blend ROIs") -->
output[Output: Blended Tensor]
| PARAMETER | DESCRIPTION |
|---|---|
alpha
|
Blending factor or sampler.
TYPE:
|
intensity_shift
|
Intensity offset WRT mean=0, std=0 background.
TYPE:
|
Source code in SynthShapes/blending.py
forward
Forward pass of Blender to apply the blending operation and return
the blended tensor.
| PARAMETER | DESCRIPTION |
|---|---|
foreground
|
The tensor with shapes to blend (each shape should have a unique ID).
TYPE:
|
background
|
The intensity image (tensor) to blend shapes into.
TYPE:
|