org.canova.image.mnist

Class MnistManager



  • public class MnistManagerextends Object

    Utility class for working with the MNIST database.

    Provides methods for traversing the images and labels data files separately, as well as simultaneously.

    Provides also method for exporting an image by writing it as a PPM file.

    Example usage:

      MnistManager m = new MnistManager("t10k-images.idx3-ubyte", "t10k-labels.idx1-ubyte");  m.setCurrent(10); //index of the image that we are interested in  int[][] image = m.readImage();  System.out.println("Label:" + m.readLabel());  MnistManager.writeImageToPpm(image, "10.ppm"); 

    • Constructor Detail

      • MnistManager

        public MnistManager(String imagesFile,                    String labelsFile)             throws IOException
        Constructs an instance managing the two given data files. Supports NULL value for one of the arguments in case reading only one of the files (images and labels) is required.
        Parameters:
        imagesFile - Can be NULL. In that case all future operations using that file will fail.
        labelsFile - Can be NULL. In that case all future operations using that file will fail.
        Throws:
        IOException
    • Method Detail

      • writeImageToPpm

        public static void writeImageToPpm(int[][] image,                                   String ppmFileName)                            throws IOException
        Writes the given image in the given file using the PPM data format.
        Parameters:
        image -
        ppmFileName -
        Throws:
        IOException
      • readImage

        public int[][] readImage()                  throws IOException
        Reads the current image.
        Returns:
        matrix
        Throws:
        IOException
      • setCurrent

        public void setCurrent(int index)
        Set the position to be read.
        Parameters:
        index -

Copyright © 2015. All rights reserved.



NOTHING
NOTHING
Add the Maven Dependecy to your project: maven dependecy for com.amazonaws : aws-java-sdk : 1.3.14