Package ai.djl.modality.cv
Class ImageFactory
java.lang.Object
ai.djl.modality.cv.ImageFactory
- Direct Known Subclasses:
BufferedImageFactory
ImageFactory
contains image creation mechanism on top of different platforms like PC and
Android. System will choose appropriate Factory based on the supported image type.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract Image
GetsImage
from file.abstract Image
GetsImage
from varies Java image types.abstract Image
GetsImage
fromInputStream
.abstract Image
fromNDArray
(NDArray array) abstract Image
fromPixels
(int[] pixels, int width, int height) GetsImage
from array.GetsImage
from URL.GetsImage
from URL.static ImageFactory
Gets new instance of Image factory from the provided factory implementation.static void
setImageFactory
(ImageFactory factory) Sets a custom instance ofImageFactory
.
-
Constructor Details
-
ImageFactory
public ImageFactory()
-
-
Method Details
-
getInstance
Gets new instance of Image factory from the provided factory implementation.- Returns:
ImageFactory
-
setImageFactory
Sets a custom instance ofImageFactory
.- Parameters:
factory
- a custom instance ofImageFactory
-
fromFile
GetsImage
from file.- Parameters:
path
- the path to the image- Returns:
Image
- Throws:
IOException
- Image not found or not readable
-
fromUrl
GetsImage
from URL.- Parameters:
url
- the URL to load from- Returns:
Image
- Throws:
IOException
- URL is not valid.
-
fromUrl
GetsImage
from URL.- Parameters:
url
- the String represent URL to load from- Returns:
Image
- Throws:
IOException
- URL is not valid.
-
fromInputStream
GetsImage
fromInputStream
.- Parameters:
is
-InputStream
- Returns:
Image
- Throws:
IOException
- image cannot be read from input stream.
-
fromImage
GetsImage
from varies Java image types.Image can be BufferedImage or BitMap depends on platform
- Parameters:
image
- the image object.- Returns:
Image
-
fromNDArray
- Parameters:
array
- the NDArray with CHW format- Returns:
Image
-
fromPixels
GetsImage
from array.- 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
-