ImagenForegroundMask

@PublicPreviewAPI
public final class ImagenForegroundMask extends ImagenMaskReference


A generated mask image which will auto-detect and mask out the foreground. The background will be black, and the foreground white

Deprecation Notice: All Imagen models are deprecated and will shut down as early as June 2026. As a replacement, you can migrate your apps to use Gemini Image models (the 'Nano Banana' models)

Summary

Public constructors

Public constructors

ImagenForegroundMask

public ImagenForegroundMask(Double dilation)
Parameters
Double dilation

the amount to dilate the mask. This can help smooth the borders of an edit and make it seem more convincing. For example, 0.05 will dilate the mask 5%.