Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Image

This class is used to import image into tf.Tensor, export tf.Tensor as an image and convert image tensor color space.

Hierarchy

  • Image

Index

Constructors

constructor

  • new Image(image: ImageBitmap, mode?: string): Image
  • Construct a new Image instance.

    Parameters

    • image: ImageBitmap

      Image coding as ImageBitMap with RGB color space.

    • mode: string = 'RGB'

      Image target color space for tensor computing.

    Returns Image

Accessors

image

  • get image(): Promise<ImageBitmap>
  • a promise that resolves when inner tensor could be export as an image.

    Returns Promise<ImageBitmap>

initialized

  • get initialized(): boolean
  • Whether the image is ready to operate.

    Returns boolean

mode

  • get mode(): string
  • set mode(mode: string): void
  • The color space of current Image instance.

    Returns string

  • The color space of current Image instance.

    Parameters

    • mode: string

    Returns void

tensor

  • get tensor(): Tensor3D
  • set tensor(tensor: Tensor3D): void
  • Inner tf.Tensor instance of current Image instance.

    Returns Tensor3D

  • Inner tf.Tensor instance of current Image instance.

    Parameters

    • tensor: Tensor3D

    Returns void

Methods

destroy

  • destroy(): void
  • Memory used by tf.Tensor in the Image instance can not be free automatically, call this if the instance won't be used;

    Returns void

waitForReader

  • waitForReader(): Promise<void>
  • Wait until the image if ready to operate.

    ```ts import { Image } from 'waifu2x-tfjs';

    async function example() { const img = new Image(anImageBitMap'); if (!img.initialized) await img.waitForReader(); } example(); ```

    Returns Promise<void>

Static rgbToYcbcr

  • rgbToYcbcr(image: Tensor3D): Tensor3D
  • Parameters

    • image: Tensor3D

      RGB Image to be converted to YCbCr with shape (H, W, 3).

    Returns Tensor3D

    YCbCr version of the image with shape (H, W, 3).

Static ycbcrToRgb

  • ycbcrToRgb(image: Tensor3D): Tensor3D
  • Parameters

    • image: Tensor3D

      YCbCr Image to be converted to RGB with shape (H, W, 3).

    Returns Tensor3D

    RGB version of the image with shape (H, W, 3).

Generated using TypeDoc