Skip to main content
A growing collection of fragments of example code…

Images and Masks

Load an image

Load an image into a batch of size 1 (based on LoadImage source code in nodes.py)

Save an image batch

Save a batch of images (based on SaveImage source code in nodes.py)

Invert a mask

Inverting a mask is a straightforward process. Since masks are normalised to the range [0,1]:

Convert a mask to Image shape

Using Masks as Transparency Layers

When used for tasks like inpainting or segmentation, the MASK’s values will eventually be rounded to the nearest integer so that they are binary — 0 indicating regions to be ignored and 1 indicating regions to be targeted. However, this doesn’t happen until the MASK is passed to those nodes. This flexibility allows you to use MASKs as you would in digital photography contexts as a transparency layer:

Noise

Creating noise variations

Here’s an example of creating a noise object which mixes the noise from two sources. This could be used to create slight noise variations by varying weight2.