public final class BufferedImageUtils
extends java.lang.Object
BufferedImageUtils
is an image processing utility to load, reshape and convert images
using BufferedImage
.Modifier and Type | Method and Description |
---|---|
static java.awt.image.BufferedImage |
fromFile(java.nio.file.Path path)
Loads the image from the specified file.
|
static java.awt.image.BufferedImage |
fromUrl(java.lang.String url)
Loads the image from the specified URL.
|
static java.awt.image.BufferedImage |
fromUrl(java.net.URL url)
Loads the image from the specified URL.
|
static java.awt.Color |
randomColor()
Returns a random color.
|
static NDArray |
readFileToArray(NDManager manager,
java.nio.file.Path path)
Reads an image file and converts to NDArray.
|
static NDArray |
readFileToArray(NDManager manager,
java.nio.file.Path path,
NDImageUtils.Flag flag)
Reads an image file and converts to NDArray.
|
static NDArray |
toNDArray(NDManager manager,
java.awt.image.BufferedImage image)
Converts a
BufferedImage to an RGB NDArray. |
static NDArray |
toNDArray(NDManager manager,
java.awt.image.BufferedImage image,
NDImageUtils.Flag flag)
Converts a
BufferedImage to an NDArray with designated color mode. |
public static java.awt.image.BufferedImage fromFile(java.nio.file.Path path) throws java.io.IOException
path
- the path of the file to be loadedBufferedImage
java.io.IOException
- if file is not foundpublic static java.awt.image.BufferedImage fromUrl(java.net.URL url) throws java.io.IOException
url
- the URL of the file to be loadedBufferedImage
java.io.IOException
- if url is not foundpublic static java.awt.image.BufferedImage fromUrl(java.lang.String url) throws java.io.IOException
url
- the URL of the file to be loadedBufferedImage
java.io.IOException
- if url is not foundpublic static java.awt.Color randomColor()
public static NDArray toNDArray(NDManager manager, java.awt.image.BufferedImage image)
BufferedImage
to an RGB NDArray.public static NDArray toNDArray(NDManager manager, java.awt.image.BufferedImage image, NDImageUtils.Flag flag)
BufferedImage
to an NDArray with designated color mode.public static NDArray readFileToArray(NDManager manager, java.nio.file.Path path) throws java.io.IOException
Returns an image with Color mode.
manager
- a NDManager
to create the new NDArray withpath
- the path to the image filejava.io.IOException
- if file is not foundpublic static NDArray readFileToArray(NDManager manager, java.nio.file.Path path, NDImageUtils.Flag flag) throws java.io.IOException
manager
- a NDManager
to create the new NDArray withpath
- the path to the image fileflag
- the color option to load withjava.io.IOException
- if file is not found