|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectmnist.tools.MnistManager
public class MnistManager
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 Summary | |
|---|---|
MnistManager(java.lang.String imagesFile,
java.lang.String labelsFile)
Constructs an instance managing the two given data files. |
|
| Method Summary | |
|---|---|
MnistImageFile |
getImages()
Get the underlying images file as MnistImageFile. |
MnistLabelFile |
getLabels()
Get the underlying labels file as MnistLabelFile. |
int[][] |
readImage()
Reads the current image. |
int |
readLabel()
Reads the current label. |
void |
setCurrent(int index)
Set the position to be read. |
static void |
writeImageToPpm(int[][] image,
java.lang.String ppmFileName)
Writes the given image in the given file using the PPM data format. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MnistManager(java.lang.String imagesFile,
java.lang.String labelsFile)
throws java.io.IOException
NULL value for one of the arguments in case reading only one
of the files (images and labels) is required.
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.
java.io.IOException| Method Detail |
|---|
public static void writeImageToPpm(int[][] image,
java.lang.String ppmFileName)
throws java.io.IOException
image - ppmFileName -
java.io.IOException
public int[][] readImage()
throws java.io.IOException
java.io.IOExceptionpublic void setCurrent(int index)
index -
public int readLabel()
throws java.io.IOException
java.io.IOExceptionpublic MnistImageFile getImages()
MnistImageFile.
MnistImageFile.public MnistLabelFile getLabels()
MnistLabelFile.
MnistLabelFile.
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||