I want to make a program recognize a figure in an image. I follow the tutorial at scikit learn .
I can train and fit the svm classifier as shown below.
First I import the libraries and dataset
from sklearn import datasets, svm, metrics digits = datasets.load_digits() n_samples = len(digits.images) data = digits.images.reshape((n_samples, -1))
Secondly, I create an SVM model and train it with a dataset.
classifier = svm.SVC(gamma = 0.001) classifier.fit(data[:n_samples], digits.target[:n_samples])
And then, I try to read my own image and use the predict() function to recognize the digit.
Here is my image: 
I convert the image to (8, 8) and then convert it to a 1D array .
img = misc.imread("w1.jpg") img = misc.imresize(img, (8, 8)) img = img[:, :, 0]
Finally, when I print the forecast , it returns [1]
predicted = classifier.predict(img.reshape((1,img.shape[0]*img.shape[1] ))) print predicted
No matter what I take pictures of other users, it still returns [1]

When I print out the " default dataset from number 9, it looks like this: 
My image number is "9":

You can see that the nonzero number is quite large for my image.
I do not know why. I am looking for help to solve my problem. Thanks