ImagenMaskReference

@PublicPreviewAPI
public abstract class ImagenMaskReference extends 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

Nested types

public static class ImagenMaskReference.Companion

Public methods

static final @NonNull List<@NonNull ImagenReferenceImage>
generateMaskAndPadForOutpainting(
    @NonNull ImagenInlineImage image,
    @NonNull Dimensions newDimensions,
    @NonNull ImagenImagePlacement newPosition
)

Generates two reference images of ImagenRawImage and ImagenRawMask.

static final @NonNull List<@NonNull ImagenReferenceImage>
generateMaskAndPadForOutpainting(
    @NonNull ImagenInlineImage image,
    @NonNull Dimensions newDimensions,
    @NonNull ImagenImagePlacement newPosition,
    double dilation
)

Generates two reference images of ImagenRawImage and ImagenRawMask.

Public methods

generateMaskAndPadForOutpainting

public static final @NonNull List<@NonNull ImagenReferenceImagegenerateMaskAndPadForOutpainting(
    @NonNull ImagenInlineImage image,
    @NonNull Dimensions newDimensions,
    @NonNull ImagenImagePlacement newPosition
)

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
@NonNull ImagenInlineImage image

the original image

@NonNull Dimensions newDimensions

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

@NonNull ImagenImagePlacement newPosition

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

generateMaskAndPadForOutpainting

public static final @NonNull List<@NonNull ImagenReferenceImagegenerateMaskAndPadForOutpainting(
    @NonNull ImagenInlineImage image,
    @NonNull Dimensions newDimensions,
    @NonNull ImagenImagePlacement newPosition,
    double dilation
)

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
@NonNull ImagenInlineImage image

the original image

@NonNull Dimensions newDimensions

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

@NonNull ImagenImagePlacement newPosition

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

double dilation

the dilation for the outpainting mask. See: ImagenRawMask.