public class ImageLoader extends BaseImageLoader
ALLOWED_FORMATS, BASE_DIR, centerCropIfNeeded, channels, height, imageTransform, log, rng, width
Constructor and Description |
---|
ImageLoader() |
ImageLoader(int height,
int width)
Instantiate an image with the given
height and width
|
ImageLoader(int height,
int width,
int channels)
Instantiate an image with the given
height and width
|
ImageLoader(int height,
int width,
int channels,
boolean centerCropIfNeeded)
Instantiate an image with the given
height and width
|
Modifier and Type | Method and Description |
---|---|
org.nd4j.linalg.api.ndarray.INDArray |
asImageMiniBatches(java.io.File f,
int numMiniBatches,
int numRowsPerSlice)
Slices up an image in to a mini batch.
|
org.nd4j.linalg.api.ndarray.INDArray |
asMatrix(java.awt.image.BufferedImage image)
Convert an BufferedImage to a matrix
|
org.nd4j.linalg.api.ndarray.INDArray |
asMatrix(java.io.File f)
Convert an image file
in to a matrix
|
org.nd4j.linalg.api.ndarray.INDArray |
asMatrix(java.io.InputStream inputStream)
Convert an input stream to a matrix
|
org.nd4j.linalg.api.ndarray.INDArray |
asRowVector(java.awt.image.BufferedImage image)
Convert an image in to a row vector
|
org.nd4j.linalg.api.ndarray.INDArray |
asRowVector(java.io.File f)
Convert a file to a row vector
|
org.nd4j.linalg.api.ndarray.INDArray |
asRowVector(java.io.InputStream inputStream) |
java.awt.image.BufferedImage |
centerCropIfNeeded(java.awt.image.BufferedImage img) |
int[] |
flattenedImageFromFile(java.io.File f) |
int[][] |
fromFile(java.io.File file)
Load a rastered image from file
|
int[][][] |
fromFileMultipleChannels(java.io.File file)
Load a rastered image from file
|
protected java.awt.image.BufferedImage |
scalingIfNeed(java.awt.image.BufferedImage image,
boolean needAlpha) |
protected java.awt.image.BufferedImage |
scalingIfNeed(java.awt.image.BufferedImage image,
int dstHeight,
int dstWidth,
boolean needAlpha) |
org.nd4j.linalg.api.ndarray.INDArray |
toBgr(java.awt.image.BufferedImage image)
Convert an BufferedImage to an bgr spectrum image
|
org.nd4j.linalg.api.ndarray.INDArray |
toBgr(java.io.File file)
Convert an input stream to an bgr spectrum image
|
org.nd4j.linalg.api.ndarray.INDArray |
toBgr(java.io.InputStream inputStream)
Convert an input stream to an bgr spectrum image
|
static java.awt.image.BufferedImage |
toBufferedImage(java.awt.Image img,
int type)
Converts a given Image into a BufferedImage
|
void |
toBufferedImageRGB(org.nd4j.linalg.api.ndarray.INDArray arr,
java.awt.image.BufferedImage image)
Convert the given image to an rgb image
|
static java.awt.image.BufferedImage |
toImage(org.nd4j.linalg.api.ndarray.INDArray matrix)
Convert a matrix in to a buffereed image
|
protected org.nd4j.linalg.api.ndarray.INDArray |
toINDArrayBGR(java.awt.image.BufferedImage image) |
protected int[][] |
toIntArrayArray(java.awt.image.BufferedImage image) |
org.nd4j.linalg.api.ndarray.INDArray |
toRaveledTensor(java.awt.image.BufferedImage image)
Convert an image in to a raveled tensor of
the bgr values of the image
|
org.nd4j.linalg.api.ndarray.INDArray |
toRaveledTensor(java.io.File file)
Changes the input stream in to an
bgr based raveled(flattened) vector
|
org.nd4j.linalg.api.ndarray.INDArray |
toRaveledTensor(java.io.InputStream is)
Changes the input stream in to an
bgr based raveled(flattened) vector
|
downloadAndUntar, getAllowedFormats
public ImageLoader()
public ImageLoader(int height, int width)
height
- the height to load*width
- the width to loadpublic ImageLoader(int height, int width, int channels)
height
- the height to loadwidth
- the width to loadchannels
- the number of channels for the image*public ImageLoader(int height, int width, int 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 org.nd4j.linalg.api.ndarray.INDArray asRowVector(java.io.File f) throws java.io.IOException
asRowVector
in class BaseImageLoader
f
- the image to convertjava.io.IOException
public org.nd4j.linalg.api.ndarray.INDArray asRowVector(java.io.InputStream inputStream) throws java.io.IOException
asRowVector
in class BaseImageLoader
java.io.IOException
public org.nd4j.linalg.api.ndarray.INDArray asRowVector(java.awt.image.BufferedImage image)
image
- the image to convertpublic org.nd4j.linalg.api.ndarray.INDArray toRaveledTensor(java.io.File file)
file
- the input stream to convertpublic org.nd4j.linalg.api.ndarray.INDArray toRaveledTensor(java.io.InputStream is)
is
- the input stream to convertpublic org.nd4j.linalg.api.ndarray.INDArray toRaveledTensor(java.awt.image.BufferedImage image)
image
- the image to parsepublic org.nd4j.linalg.api.ndarray.INDArray toBgr(java.io.File file)
file
- the file to convertpublic org.nd4j.linalg.api.ndarray.INDArray toBgr(java.io.InputStream inputStream)
inputStream
- the input stream to convertpublic org.nd4j.linalg.api.ndarray.INDArray toBgr(java.awt.image.BufferedImage image)
image
- the BufferedImage to convertpublic org.nd4j.linalg.api.ndarray.INDArray asMatrix(java.io.File f) throws java.io.IOException
asMatrix
in class BaseImageLoader
f
- the file to convertjava.io.IOException
public org.nd4j.linalg.api.ndarray.INDArray asMatrix(java.io.InputStream inputStream) throws java.io.IOException
asMatrix
in class BaseImageLoader
inputStream
- the input stream to convertjava.io.IOException
public org.nd4j.linalg.api.ndarray.INDArray asMatrix(java.awt.image.BufferedImage image)
image
- the BufferedImage to convertpublic org.nd4j.linalg.api.ndarray.INDArray asImageMiniBatches(java.io.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(java.io.File f) throws java.io.IOException
java.io.IOException
public int[][] fromFile(java.io.File file) throws java.io.IOException
file
- the file to loadjava.io.IOException
public int[][][] fromFileMultipleChannels(java.io.File file) throws java.io.IOException
file
- the file to loadjava.io.IOException
public static java.awt.image.BufferedImage toImage(org.nd4j.linalg.api.ndarray.INDArray matrix)
matrix
- theBufferedImage
public void toBufferedImageRGB(org.nd4j.linalg.api.ndarray.INDArray arr, java.awt.image.BufferedImage image)
arr
- the array to useimage
- the image to setpublic static java.awt.image.BufferedImage toBufferedImage(java.awt.Image img, int type)
img
- The Image to be convertedtype
- The color model of BufferedImageprotected int[][] toIntArrayArray(java.awt.image.BufferedImage image)
protected org.nd4j.linalg.api.ndarray.INDArray toINDArrayBGR(java.awt.image.BufferedImage image)
public java.awt.image.BufferedImage centerCropIfNeeded(java.awt.image.BufferedImage img)
protected java.awt.image.BufferedImage scalingIfNeed(java.awt.image.BufferedImage image, boolean needAlpha)
protected java.awt.image.BufferedImage scalingIfNeed(java.awt.image.BufferedImage image, int dstHeight, int dstWidth, boolean needAlpha)