ImagenMaskReference

@PublicPreviewAPI
abstract class ImagenMaskReference : ImagenReferenceImage

Known direct subclasses
ImagenBackgroundMask

A generated mask image which will auto-detect and mask out the background.

ImagenForegroundMask

A generated mask image which will auto-detect and mask out the foreground.

ImagenRawMask

Represents a mask for Imagen editing.

ImagenSemanticMask

Represents a generated mask for Imagen editing which masks out certain objects using object detection.


Represents a mask for Imagen editing. This image (generated or provided) should contain only black and white pixels, with black representing parts of the image which should not change.

Summary

Public companion functions

List<ImagenReferenceImage>
generateMaskAndPadForOutpainting(
    image: ImagenInlineImage,
    newDimensions: Dimensions,
    newPosition: ImagenImagePlacement
)

Generates two reference images of ImagenRawImage and ImagenRawMask.

List<ImagenReferenceImage>
generateMaskAndPadForOutpainting(
    image: ImagenInlineImage,
    newDimensions: Dimensions,
    newPosition: ImagenImagePlacement,
    dilation: Double
)

Generates two reference images of ImagenRawImage and ImagenRawMask.

Public companion functions

generateMaskAndPadForOutpainting

fun generateMaskAndPadForOutpainting(
    image: ImagenInlineImage,
    newDimensions: Dimensions,
    newPosition: ImagenImagePlacement = ImagenImagePlacement.CENTER
): List<ImagenReferenceImage>

Generates two reference images of ImagenRawImage and ImagenRawMask. These images are generated in this order:

  • One ImagenRawImage containing the original image, padded out to the new dimensions with black pixels, with the original image placed at the given placement

  • One ImagenRawMask of the same dimensions containing white everywhere except at the placement original image. This is the format expected by Imagen for outpainting requests.

Parameters
image: ImagenInlineImage

the original image

newDimensions: Dimensions

the new dimensions for outpainting. These new dimensions must be more than the original image.

newPosition: ImagenImagePlacement = ImagenImagePlacement.CENTER

the placement of the original image within the new outpainted image.

generateMaskAndPadForOutpainting

fun generateMaskAndPadForOutpainting(
    image: ImagenInlineImage,
    newDimensions: Dimensions,
    newPosition: ImagenImagePlacement = ImagenImagePlacement.CENTER,
    dilation: Double = 0.01
): List<ImagenReferenceImage>

Generates two reference images of ImagenRawImage and ImagenRawMask. These images are generated in this order:

  • One ImagenRawImage containing the original image, padded out to the new dimensions with black pixels, with the original image placed at the given placement

  • One ImagenRawMask of the same dimensions containing white everywhere except at the placement original image. This is the format expected by Imagen for outpainting requests.

Parameters
image: ImagenInlineImage

the original image

newDimensions: Dimensions

the new dimensions for outpainting. These new dimensions must be more than the original image.

newPosition: ImagenImagePlacement = ImagenImagePlacement.CENTER

the placement of the original image within the new outpainted image.

dilation: Double = 0.01

the dilation for the outpainting mask. See: ImagenRawMask.