ImageConverter

object ImageConverter

Helper object with methods to convert BufferedImage to FloatArray.

See also

Functions

floatArrayToBufferedImage
Link copied to clipboard
fun floatArrayToBufferedImage(inputArray: FloatArray, outputShape: TensorShape, arrayColorMode: ColorMode, isNormalized: Boolean): BufferedImage

Converts inputArray of type FloatArray to BufferedImage with outputShape provided.

fun floatArrayToBufferedImage(inputArray: FloatArray, width: Int, height: Int, arrayColorMode: ColorMode, isNormalized: Boolean): BufferedImage

Converts inputArray of type FloatArray to BufferedImage with width and height provided.

fun floatArrayToBufferedImage(inputArray: FloatArray, width: Int, height: Int, arrayColorMode: ColorMode, arrayTransform: ArrayTransform? = null): BufferedImage

Converts inputArray of type FloatArray to BufferedImage with width and height provided. If a custom arrayTransform is needed, lambda or ArrayTransform can be provided.

imageTo3DFloatArray
Link copied to clipboard
fun imageTo3DFloatArray(image: BufferedImage, colorMode: ColorMode = ColorMode.BGR): Array<Array<FloatArray>>

Converts image with colorMode to the 3D array.

swapRandB
Link copied to clipboard
fun swapRandB(image: FloatArray)

Given a float array representing an image, swaps red and green channels in it.

toBufferedImage
Link copied to clipboard
fun toBufferedImage(file: File): BufferedImage

Returns BufferedImage extracted from file.

fun toBufferedImage(inputStream: InputStream): BufferedImage

Returns BufferedImage extracted from inputStream.

toNormalizedFloatArray
Link copied to clipboard
fun toNormalizedFloatArray(image: BufferedImage, colorMode: ColorMode? = null): FloatArray

Converts image to FloatArray and scales the values, so they would fit into the [0, 1) range.

fun toNormalizedFloatArray(imageFile: File, colorMode: ColorMode? = null): FloatArray

Reads the image from imageFile, converts it to FloatArray and scales the values, so they would fit into the [0, 1) range.

fun toNormalizedFloatArray(inputStream: InputStream, colorMode: ColorMode? = null): FloatArray

Reads the image from inputStream, converts it to FloatArray and scales the values, so they would fit into the [0, 1) range.

toRawFloatArray
Link copied to clipboard
fun toRawFloatArray(image: BufferedImage, colorMode: ColorMode? = null): FloatArray

Converts image to FloatArray without normalization.

fun toRawFloatArray(imageFile: File, colorMode: ColorMode? = null): FloatArray

Reads the image from imageFile and converts it to FloatArray without normalization.

fun toRawFloatArray(inputStream: InputStream, colorMode: ColorMode? = null): FloatArray

Reads the image from inputStream and converts it to FloatArray without normalization.