public class ImageLoader extends BaseImageLoader
BaseImageLoader.MultiPageModeALLOWED_FORMATS, centerCropIfNeeded, channels, height, imageTransform, multiPageMode, rng, width| Constructor and Description |
|---|
ImageLoader() |
ImageLoader(long height,
long width)
Instantiate an image with the given
height and width
|
ImageLoader(long height,
long width,
long channels)
Instantiate an image with the given
height and width
|
ImageLoader(long height,
long width,
long channels,
boolean centerCropIfNeeded)
Instantiate an image with the given
height and width
|
| Modifier and Type | Method and Description |
|---|---|
Image |
asImageMatrix(File f)
As per
BaseImageLoader.asMatrix(File) but as an Image |
Image |
asImageMatrix(File f,
boolean nchw)
As per
BaseImageLoader.asMatrix(File, boolean) but as an Image |
Image |
asImageMatrix(InputStream inputStream)
As per
BaseImageLoader.asMatrix(InputStream) but as an Image |
Image |
asImageMatrix(InputStream inputStream,
boolean nchw)
As per
BaseImageLoader.asMatrix(InputStream, boolean) but as an Image |
INDArray |
asImageMiniBatches(File f,
int numMiniBatches,
int numRowsPerSlice)
Slices up an image in to a mini batch.
|
INDArray |
asMatrix(BufferedImage image)
Convert an BufferedImage to a matrix
|
INDArray |
asMatrix(File f)
Convert an image file
in to a matrix
|
INDArray |
asMatrix(File f,
boolean nchw)
Load an image from a file to an INDArray
|
INDArray |
asMatrix(InputStream inputStream)
Convert an input stream to a matrix
|
INDArray |
asMatrix(InputStream inputStream,
boolean nchw)
Load an image file from an input stream to an INDArray
|
INDArray |
asRowVector(BufferedImage image)
Convert an image in to a row vector
|
INDArray |
asRowVector(File f)
Convert a file to a row vector
|
INDArray |
asRowVector(InputStream inputStream) |
BufferedImage |
centerCropIfNeeded(BufferedImage img) |
int[] |
flattenedImageFromFile(File f) |
int[][] |
fromFile(File file)
Load a rastered image from file
|
int[][][] |
fromFileMultipleChannels(File file)
Load a rastered image from file
|
protected BufferedImage |
scalingIfNeed(BufferedImage image,
boolean needAlpha) |
protected BufferedImage |
scalingIfNeed(BufferedImage image,
long dstHeight,
long dstWidth,
long dstImageType,
boolean needAlpha) |
INDArray |
toBgr(BufferedImage image)
Convert an BufferedImage to an bgr spectrum image
|
INDArray |
toBgr(File file)
Convert an input stream to an bgr spectrum image
|
INDArray |
toBgr(InputStream inputStream)
Convert an input stream to an bgr spectrum image
|
static BufferedImage |
toBufferedImage(Image img,
int type)
Converts a given Image into a BufferedImage
|
void |
toBufferedImageRGB(INDArray arr,
BufferedImage image)
Convert the given image to an rgb image
|
static BufferedImage |
toImage(INDArray matrix)
Convert a matrix in to a buffereed image
|
protected INDArray |
toINDArrayBGR(BufferedImage image) |
protected int[][] |
toIntArrayArray(BufferedImage image) |
INDArray |
toRaveledTensor(BufferedImage image)
Convert an image in to a raveled tensor of
the bgr values of the image
|
INDArray |
toRaveledTensor(File file)
Changes the input stream in to an
bgr based raveled(flattened) vector
|
INDArray |
toRaveledTensor(InputStream is)
Changes the input stream in to an
bgr based raveled(flattened) vector
|
downloadAndUntar, getAllowedFormatspublic ImageLoader()
public ImageLoader(long height,
long width)
height - the height to load*width - the width to loadpublic ImageLoader(long height,
long width,
long channels)
height - the height to loadwidth - the width to loadchannels - the number of channels for the image*public ImageLoader(long height,
long width,
long channels,
boolean centerCropIfNeeded)
height - the height to loadwidth - the width to loadchannels - the number of channels for the image*centerCropIfNeeded - to crop before rescaling and convertingpublic INDArray asRowVector(File f) throws IOException
asRowVector in class BaseImageLoaderf - the image to convertIOExceptionpublic INDArray asRowVector(InputStream inputStream) throws IOException
asRowVector in class BaseImageLoaderIOExceptionpublic INDArray asRowVector(BufferedImage image)
image - the image to convertpublic INDArray toRaveledTensor(File file)
file - the input stream to convertpublic INDArray toRaveledTensor(InputStream is)
is - the input stream to convertpublic INDArray toRaveledTensor(BufferedImage image)
image - the image to parsepublic INDArray toBgr(File file)
file - the file to convertpublic INDArray toBgr(InputStream inputStream)
inputStream - the input stream to convertpublic INDArray toBgr(BufferedImage image)
image - the BufferedImage to convertpublic INDArray asMatrix(File f) throws IOException
asMatrix in class BaseImageLoaderf - the file to convertIOExceptionpublic INDArray asMatrix(File f, boolean nchw) throws IOException
BaseImageLoaderasMatrix in class BaseImageLoaderf - File to load the image fromnchw - If true: return image in NCHW/channels_first [1, channels, height width] format; if false, return
in NHWC/channels_last [1, height, width, channels] formatIOExceptionpublic INDArray asMatrix(InputStream inputStream) throws IOException
asMatrix in class BaseImageLoaderinputStream - the input stream to convertIOExceptionpublic INDArray asMatrix(InputStream inputStream, boolean nchw) throws IOException
BaseImageLoaderasMatrix in class BaseImageLoaderinputStream - Input stream to load the image fromnchw - If true: return image in NCHW/channels_first [1, channels, height width] format; if false, return
in NHWC/channels_last [1, height, width, channels] formatIOExceptionpublic Image asImageMatrix(File f) throws IOException
BaseImageLoaderBaseImageLoader.asMatrix(File) but as an ImageasImageMatrix in class BaseImageLoaderIOExceptionpublic Image asImageMatrix(File f, boolean nchw) throws IOException
BaseImageLoaderBaseImageLoader.asMatrix(File, boolean) but as an ImageasImageMatrix in class BaseImageLoaderIOExceptionpublic Image asImageMatrix(InputStream inputStream) throws IOException
BaseImageLoaderBaseImageLoader.asMatrix(InputStream) but as an ImageasImageMatrix in class BaseImageLoaderIOExceptionpublic Image asImageMatrix(InputStream inputStream, boolean nchw) throws IOException
BaseImageLoaderBaseImageLoader.asMatrix(InputStream, boolean) but as an ImageasImageMatrix in class BaseImageLoaderIOExceptionpublic INDArray asMatrix(BufferedImage image)
image - the BufferedImage to convertpublic INDArray asImageMiniBatches(File f, int numMiniBatches, int numRowsPerSlice)
f - the file to load fromnumMiniBatches - the number of images in a mini batchnumRowsPerSlice - the number of rows for each imagepublic int[] flattenedImageFromFile(File f) throws IOException
IOExceptionpublic int[][] fromFile(File file) throws IOException
file - the file to loadIOExceptionpublic int[][][] fromFileMultipleChannels(File file) throws IOException
file - the file to loadIOExceptionpublic static BufferedImage toImage(INDArray matrix)
matrix - theBufferedImagepublic void toBufferedImageRGB(INDArray arr, BufferedImage image)
arr - the array to useimage - the image to setpublic static BufferedImage toBufferedImage(Image img, int type)
img - The Image to be convertedtype - The color model of BufferedImageprotected int[][] toIntArrayArray(BufferedImage image)
protected INDArray toINDArrayBGR(BufferedImage image)
public BufferedImage centerCropIfNeeded(BufferedImage img)
protected BufferedImage scalingIfNeed(BufferedImage image, boolean needAlpha)
protected BufferedImage scalingIfNeed(BufferedImage image, long dstHeight, long dstWidth, long dstImageType, boolean needAlpha)
Copyright © 2022. All rights reserved.