Class MatrixIO

java.lang.Object
net.algart.external.MatrixIO

public class MatrixIO extends Object
  • Constructor Details

    • MatrixIO

      public MatrixIO()
  • Method Details

    • extension

      public static String extension(Path file)
    • extension

      public static String extension(Path file, String defaultExtension)
    • extension

      public static String extension(File file)
    • extension

      public static String extension(File file, String defaultExtension)
    • extension

      public static String extension(String fileName)
    • extension

      public static String extension(String fileName, String defaultExtension)
    • removeExtension

      public static String removeExtension(String fileName)
    • writeBufferedImage

      public static void writeBufferedImage(Path file, BufferedImage image) throws IOException
      Throws:
      IOException
    • readBufferedImage

      public static BufferedImage readBufferedImage(Path file) throws IOException
      Throws:
      IOException
    • writeImage

      public static void writeImage(Path file, List<? extends Matrix<? extends PArray>> image) throws IOException
      Throws:
      IOException
    • readImage

      public static List<Matrix<UpdatablePArray>> readImage(Path file) throws IOException
      Throws:
      IOException
    • clearAlgARTImageTemporaryStatus

      public static void clearAlgARTImageTemporaryStatus(List<Matrix<? extends PArray>> image)
      Should be called if you are going to call writeAlgARTImage(Path, List, boolean) with allowReferencesToStandardLargeFiles=true from an external algorithm before its finishing (to return its results).
      Parameters:
      image - matrices, for built-in arrays of which you want to clear the temporary status
    • writeAlgARTImage

      public static void writeAlgARTImage(Path folder, List<? extends Matrix<? extends PArray>> image) throws IOException
      Throws:
      IOException
    • writeAlgARTImage

      public static void writeAlgARTImage(Path folder, List<? extends Matrix<? extends PArray>> image, boolean allowReferencesToStandardLargeFiles) throws IOException
      Saves the multichannel image (list of matrices) in the specified folder. Matrices are saved in several files in very simple format without any compression. If this folder already contain an image, saved by previous call of this method, it is automatically deleted (replaced with the new one).
      Parameters:
      folder - folder to save the image.
      image - some multichannel image
      allowReferencesToStandardLargeFiles - if true, and if one of passed matrices is mapped to some file F by LargeMemoryModel, this method does not write the matrix content and saves a little text "reference" file with information about the path to this file F.
      Throws:
      IOException - in a case of I/O error.
      NullPointerException - if one of the arguments or elements of image list is null.
    • readAlgARTImage

      public static List<Matrix<? extends PArray>> readAlgARTImage(Path folder) throws IOException
      Loads the multichannel image (list of matrices), saved in the specified folder by writeAlgARTImage(Path, List) call.

      Note: the files containing the matrices retain open, and any access to the returned matrices will lead to operations with these files (mapping). Usually you should copy the returned matrices to some other memory model and call Matrix.freeResources() for them to close these files.

      Parameters:
      folder - folder with multichannel image, stored in a set of files.
      Returns:
      all channels of this image.
      Throws:
      IOException - in a case of I/O error.
      NullPointerException - if the argument is null.
    • writeAlgARTMatrix

      public static void writeAlgARTMatrix(Path folder, Matrix<? extends PArray> matrix) throws IOException
      Throws:
      IOException
    • readAlgARTMatrix

      public static Matrix<? extends PArray> readAlgARTMatrix(Path folder) throws IOException
      Throws:
      IOException
    • serializeAlgARTMatrix

      public static void serializeAlgARTMatrix(Matrix<? extends PArray> matrix, OutputStream outputStream, MatrixIO.SerializationMode serializationMode, ByteOrder byteOrder) throws IOException
      Throws:
      IOException
    • deserializeAlgARTMatrix

      public static Matrix<? extends PArray> deserializeAlgARTMatrix(InputStream inputStream, MatrixIO.SerializationMode serializationMode, MemoryModel memoryModel) throws IOException
      Throws:
      IOException