0

I want to train a SVM to perform a classification of Images of Digits (0-9) and then use it to read images with numerical values(a low level OCR).

My idea is to read images one by one and store them in numpy array and then to put all those arrays in an array, so as to make my sample_array.

As from the Scikit-Learn documentation " As other classifiers, SVC, NuSVC and LinearSVC take as input two arrays: an array X of size [n_samples, n_features] holding the training samples, and an array y of class labels (strings or integers), size [n_samples]:"

My question is what should be the features of the Images, and how to define them?

I read the Handwriting Recognition example on the tutorial page of the scikit-learn page, but over there the data is already in a dataset(even after a searching the web quite intensively I still don't know how to get my PICS to convert to a dataset) so you see it's a different situation.

A Secondary question: will scikit-image be helpful to use in this situation? I'm using standard PIL for reading images.

1
  • X is a 2D array of [n_samples x n_features] where n_samples would the number of images you have, and n_features can be pretty much anything you do on top of a single image. From the image itself, where n_features would represent all the pixels of the image flattened (this is, the image transformed from 2D to 1D) to any more complicated feature. May 22, 2015 at 13:39

1 Answer 1

3

I would say there are many examples only in SO.

each image is a row in your matrix and each column represents the colour intensity of a pixel.so for example if you have a grayscale image the value in your matrix range from 0 to 255. so your features are pixels intensity. take a look at these pages for examples.

http://matplotlib.org/users/image_tutorial.html

How can I read the RGB value of a given pixel in Python?

I recommend you to read a bit more about the basic of image processing. There are many online courses. I personally like this one:

https://www.youtube.com/playlist?list=PL8NTI-xZ0OWnuPNA8QD1BmFyBYbeKIaLM

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.