ImagenMaskReference.Companion

public static class ImagenMaskReference.Companion


Summary

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.