Andrew
Andrew

Reputation: 6394

Read an image as a matrix (Java)

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 ....

Upvotes: 1

Views: 2431

Answers (1)

Mikhail
Mikhail

Reputation: 8028

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.

Upvotes: 2

Related Questions