Package ai.djl.modality.cv
Class BufferedImageFactory
- java.lang.Object
-
- ai.djl.modality.cv.ImageFactory
-
- ai.djl.modality.cv.BufferedImageFactory
-
public class BufferedImageFactory extends ImageFactory
BufferedImageFactoryis the default implementation ofImageFactory.
-
-
Constructor Summary
Constructors Constructor Description BufferedImageFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ImagefromFile(java.nio.file.Path path)GetsImagefrom file.ImagefromImage(java.lang.Object image)GetsImagefrom varies Java image types.ImagefromInputStream(java.io.InputStream is)GetsImagefromInputStream.ImagefromNDArray(NDArray array)ImagefromPixels(int[] pixels, int width, int height)GetsImagefrom array.protected voidsave(java.awt.image.BufferedImage image, java.io.OutputStream os, java.lang.String type)-
Methods inherited from class ai.djl.modality.cv.ImageFactory
fromUrl, fromUrl, getInstance, setImageFactory
-
-
-
-
Method Detail
-
fromFile
public Image fromFile(java.nio.file.Path path) throws java.io.IOException
GetsImagefrom file.- Specified by:
fromFilein classImageFactory- Parameters:
path- the path to the image- Returns:
Image- Throws:
java.io.IOException- Image not found or not readable
-
fromInputStream
public Image fromInputStream(java.io.InputStream is) throws java.io.IOException
GetsImagefromInputStream.- Specified by:
fromInputStreamin classImageFactory- Parameters:
is-InputStream- Returns:
Image- Throws:
java.io.IOException- image cannot be read from input stream.
-
fromImage
public Image fromImage(java.lang.Object image)
GetsImagefrom varies Java image types.Image can be BufferedImage or BitMap depends on platform
- Specified by:
fromImagein classImageFactory- Parameters:
image- the image object.- Returns:
Image
-
fromNDArray
public Image fromNDArray(NDArray array)
- Specified by:
fromNDArrayin classImageFactory- Parameters:
array- the NDArray with CHW format- Returns:
Image
-
fromPixels
public Image fromPixels(int[] pixels, int width, int height)
GetsImagefrom array.- Specified by:
fromPixelsin classImageFactory- Parameters:
pixels- the array of ARGB values used to initialize the pixels.width- the width of the imageheight- the height of the image- Returns:
Image
-
save
protected void save(java.awt.image.BufferedImage image, java.io.OutputStream os, java.lang.String type) throws java.io.IOException- Throws:
java.io.IOException
-
-