֍
Generate an image, remove the background, and fill the foreground
In this example, we'll create a branching image generation workflow that:
- Generates an image using GenerateImage
- Removes the background from the image using RemoveBackground
- Generates a masked foreground from the image using RemoveBackground, with
return_mask
enabled - Fills the masked foreground using EraseImage
First, initialize Substrate:
Create and connect four nodes and run them:
![image](/_next/image?url=https%3A%2F%2Fmedia.substrate.run%2Fchesterfield.jpeg&w=640&q=75)
res.get(image)
![no background](/_next/image?url=https%3A%2F%2Fmedia.substrate.run%2Fchesterfield-no-bg.jpeg&w=640&q=75)
res.get(removeBg)
![image](/_next/image?url=https%3A%2F%2Fmedia.substrate.run%2Fchesterfield-mask.jpeg&w=640&q=75)
res.get(removeBgMask)
![image](/_next/image?url=https%3A%2F%2Fmedia.substrate.run%2Fchesterfield-only-bg.jpeg&w=640&q=75)
res.get(fillMask)