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 ImageGetsImagefrom file.abstract ImageGetsImagefrom varies Java image types.abstract ImageGetsImagefromInputStream.abstract ImagefromNDArray(NDArray array) abstract ImagefromPixels(int[] pixels, int width, int height) GetsImagefrom array.GetsImagefrom string representation.GetsImagefrom URL.static ImageFactoryGets new instance of Image factory from the provided factory implementation.static voidsetImageFactory(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
GetsImagefrom file.- Parameters:
path- the path to the image- Returns:
Image- Throws:
IOException- Image not found or not readable
-
fromUrl
GetsImagefrom URL.- Parameters:
url- the URL to load from- Returns:
Image- Throws:
IOException- URL is not valid.
-
fromUrl
GetsImagefrom string representation.- Parameters:
url- the String represent URL or base64 encoded image to load from- Returns:
Image- Throws:
IOException- URL is not valid.
-
fromInputStream
GetsImagefromInputStream.- Parameters:
is-InputStream- Returns:
Image- Throws:
IOException- image cannot be read from input stream.
-
fromImage
GetsImagefrom 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
GetsImagefrom 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
-