boofcv.io.image
Class UtilImageIO
- java.lang.Object
-
- boofcv.io.image.UtilImageIO
-
public class UtilImageIO extends java.lang.ObjectClass for loading and saving images.
-
-
Constructor Summary
Constructors Constructor and Description UtilImageIO()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static <T extends ImageBase>
TloadImage(java.io.File image, boolean orderRgb, ImageType<T> imageType)static java.awt.image.BufferedImageloadImage(java.lang.String fileName)A function that load the specified image.static <T extends ImageGray>
TloadImage(java.lang.String fileName, java.lang.Class<T> imageType)Loads the image and converts into the specified image type.static java.awt.image.BufferedImageloadImage(java.lang.String directory, java.lang.String fileName)static <T extends ImageGray>
TloadImage(java.lang.String directory, java.lang.String fileName, java.lang.Class<T> imageType)static java.awt.image.BufferedImageloadImage(java.net.URL fileName)A function that load the specified image.static java.util.List<java.awt.image.BufferedImage>loadImages(java.lang.String directory, java.lang.String regex)Loads all the image in the specified directory which match the provided regexstatic GrayU8loadPGM_U8(java.io.InputStream inputStream, GrayU8 storage)Loads a PGM image from anInputStream.static GrayU8loadPGM_U8(java.lang.String fileName, GrayU8 storage)Loads a PGM image from anInputStream.static java.awt.image.BufferedImageloadPGM(java.io.InputStream inputStream, java.awt.image.BufferedImage storage)Loads a PGM image from anInputStream.static java.awt.image.BufferedImageloadPGM(java.lang.String fileName, java.awt.image.BufferedImage storage)Loads a PGM image from a file.static Planar<GrayU8>loadPPM_U8(java.io.InputStream inputStream, Planar<GrayU8> storage, GrowQueue_I8 temp)Reads a PPM image file directly into a Planarimage. static Planar<GrayU8>loadPPM_U8(java.lang.String fileName, Planar<GrayU8> storage, GrowQueue_I8 temp)Reads a PPM image file directly into a Planarimage. static java.awt.image.BufferedImageloadPPM(java.io.InputStream inputStream, java.awt.image.BufferedImage storage)Loads a PPM image from anInputStream.static java.awt.image.BufferedImageloadPPM(java.lang.String fileName, java.awt.image.BufferedImage storage)Loads a PPM image from a file.static voidsaveImage(java.awt.image.BufferedImage img, java.lang.String fileName)Saves theBufferedImageto the specified file.static voidsaveImage(ImageBase image, java.lang.String fileName)Saves the BoofCV formatted image.static voidsavePGM(GrayU8 gray, java.lang.String fileName)Saves an image in PGM format.static voidsavePPM(Planar<GrayU8> rgb, java.lang.String fileName, GrowQueue_I8 temp)Saves an image in PPM format.
-
-
-
Method Detail
-
loadImage
public static java.awt.image.BufferedImage loadImage(java.lang.String fileName)
A function that load the specified image. If anything goes wrong it returns a null.
-
loadImage
public static java.awt.image.BufferedImage loadImage(java.lang.String directory, java.lang.String fileName)
-
loadImages
public static java.util.List<java.awt.image.BufferedImage> loadImages(java.lang.String directory, java.lang.String regex)Loads all the image in the specified directory which match the provided regex- Parameters:
directory- File directoryregex- Regex used to match file names- Returns:
- List of found images.
-
loadImage
public static java.awt.image.BufferedImage loadImage(java.net.URL fileName)
A function that load the specified image. If anything goes wrong it returns a null.
-
loadImage
public static <T extends ImageGray> T loadImage(java.lang.String fileName, java.lang.Class<T> imageType)
Loads the image and converts into the specified image type.- Parameters:
fileName- Path to image file.imageType- Type of image that should be returned.- Returns:
- The image or null if the image could not be loaded.
-
loadImage
public static <T extends ImageGray> T loadImage(java.lang.String directory, java.lang.String fileName, java.lang.Class<T> imageType)
-
loadImage
public static <T extends ImageBase> T loadImage(java.io.File image, boolean orderRgb, ImageType<T> imageType)
-
saveImage
public static void saveImage(java.awt.image.BufferedImage img, java.lang.String fileName)Saves theBufferedImageto the specified file. The image type of the output is determined by the name's extension. By default the file is saved usingImageIO.write(RenderedImage, String, File)} but if that fails then it will see if it can save it using BoofCV native code for PPM and PGM.- Parameters:
img- Image which is to be saved.fileName- Name of the output file. The type is determined by the extension.
-
saveImage
public static void saveImage(ImageBase image, java.lang.String fileName)
Saves the BoofCV formatted image. This is identical to the following code:
BufferedImage out = ConvertBufferedImage.convertTo(image,null,true); saveImage(out,fileName);
- Parameters:
image- Image which is to be saved.fileName- Name of the output file. The type is determined by the extension.
-
loadPPM
public static java.awt.image.BufferedImage loadPPM(java.lang.String fileName, java.awt.image.BufferedImage storage) throws java.io.IOExceptionLoads a PPM image from a file.- Parameters:
fileName- Location of PPM imagestorage- (Optional) Storage for output image. Must be the width and height of the image being read. Better performance of type BufferedImage.TYPE_INT_RGB. If null or width/height incorrect a new image will be declared.- Returns:
- The read in image
- Throws:
java.io.IOException
-
loadPGM
public static java.awt.image.BufferedImage loadPGM(java.lang.String fileName, java.awt.image.BufferedImage storage) throws java.io.IOExceptionLoads a PGM image from a file.- Parameters:
fileName- Location of PGM imagestorage- (Optional) Storage for output image. Must be the width and height of the image being read. Better performance of type BufferedImage.TYPE_BYTE_GRAY. If null or width/height incorrect a new image will be declared.- Returns:
- The read in image
- Throws:
java.io.IOException
-
loadPPM
public static java.awt.image.BufferedImage loadPPM(java.io.InputStream inputStream, java.awt.image.BufferedImage storage) throws java.io.IOExceptionLoads a PPM image from anInputStream.- Parameters:
inputStream- InputStream for PPM imagestorage- (Optional) Storage for output image. Must be the width and height of the image being read. Better performance of type BufferedImage.TYPE_INT_RGB. If null or width/height incorrect a new image will be declared.- Returns:
- The read in image
- Throws:
java.io.IOException
-
loadPGM
public static java.awt.image.BufferedImage loadPGM(java.io.InputStream inputStream, java.awt.image.BufferedImage storage) throws java.io.IOExceptionLoads a PGM image from anInputStream.- Parameters:
inputStream- InputStream for PGM imagestorage- (Optional) Storage for output image. Must be the width and height of the image being read. Better performance of type BufferedImage.TYPE_BYTE_GRAY. If null or width/height incorrect a new image will be declared.- Returns:
- The read in image
- Throws:
java.io.IOException
-
loadPPM_U8
public static Planar<GrayU8> loadPPM_U8(java.lang.String fileName, Planar<GrayU8> storage, GrowQueue_I8 temp) throws java.io.IOException
Reads a PPM image file directly into a Planarimage. To improve performance when reading many images, the user can provide work space memory in the optional parameters - Parameters:
fileName- Location of PPM filestorage- (Optional) Where the image is written in to. Will be resized if needed. If null or the number of bands isn't 3, a new instance is declared.temp- (Optional) Used internally to store the image. Can be null.- Returns:
- The image.
- Throws:
java.io.IOException
-
loadPPM_U8
public static Planar<GrayU8> loadPPM_U8(java.io.InputStream inputStream, Planar<GrayU8> storage, GrowQueue_I8 temp) throws java.io.IOException
Reads a PPM image file directly into a Planarimage. To improve performance when reading many images, the user can provide work space memory in the optional parameters - Parameters:
inputStream- InputStream for PPM imagestorage- (Optional) Where the image is written in to. Will be resized if needed. If null or the number of bands isn't 3, a new instance is declared.temp- (Optional) Used internally to store the image. Can be null.- Returns:
- The image.
- Throws:
java.io.IOException
-
loadPGM_U8
public static GrayU8 loadPGM_U8(java.lang.String fileName, GrayU8 storage) throws java.io.IOException
Loads a PGM image from anInputStream.- Parameters:
fileName- InputStream for PGM imagestorage- (Optional) Storage for output image. Must be the width and height of the image being read. If null a new image will be declared.- Returns:
- The read in image
- Throws:
java.io.IOException
-
loadPGM_U8
public static GrayU8 loadPGM_U8(java.io.InputStream inputStream, GrayU8 storage) throws java.io.IOException
Loads a PGM image from anInputStream.- Parameters:
inputStream- InputStream for PGM imagestorage- (Optional) Storage for output image. Must be the width and height of the image being read. If null a new image will be declared.- Returns:
- The read in image
- Throws:
java.io.IOException
-
savePPM
public static void savePPM(Planar<GrayU8> rgb, java.lang.String fileName, GrowQueue_I8 temp) throws java.io.IOException
Saves an image in PPM format.- Parameters:
rgb- 3-band RGB imagefileName- Location where the image is to be written to.temp- (Optional) Used internally to store the image. Can be null.- Throws:
java.io.IOException
-
savePGM
public static void savePGM(GrayU8 gray, java.lang.String fileName) throws java.io.IOException
Saves an image in PGM format.- Parameters:
gray- Gray scale imagefileName- Location where the image is to be written to.- Throws:
java.io.IOException
-
-
DataMelt 3.0 © DataMelt by jWork.ORG