1

I'm planning to use MNIST database to train a classifier to recognize the hand written numbers. I have a few questions:

  1. Can I read an image as a matrix or an array of pixels?
    Two options I figured out so far is the getRGB and PixelGrabber.
  2. How can I read the MNIST database?
    I see it's of the form:
    00 00 00 00 00 00 54 B9 9F 97 3C 24 ....
Andrew
  • 6,254
  • 16
  • 59
  • 93

1 Answers1

2

http://docs.oracle.com/javase/1.4.2/docs/api/java/awt/image/BufferedImage.html Take a look at getRGB . You will get back a color array of values in a single vector/row.

This site appears to have some classes for accessing the MINST database: http://www.bcl.hamilton.ie/~barak/teach/F98/ECE547/hw1/index.html

*You want top use Java's built in classes such as BufferedImage because getting the files any other way would involve writing your own file parsers and doing so will probably be a waste of time.

Mikhail
  • 7,749
  • 11
  • 62
  • 136
  • I said that I know how to use it. The question is if there is any other way to get the pixels. – Andrew Feb 23 '12 at 18:14
  • The RGB value are "the pixels" – Mikhail Feb 23 '12 at 18:17
  • ok, I used that. It converts the images to .PPM. getRGB doesn't work on PPM files. At least I couldn't get it working. – Andrew Feb 23 '12 at 18:18
  • PPM is some silly format that is very similar to RGB. Somebody http://stackoverflow.com/questions/2693631/read-ppm-file-and-store-it-in-an-array-coded-with-c wrote some C code to read PPM. It shouldn't be too hard. – Mikhail Feb 23 '12 at 18:21