# Beginner Question: Extracting Features for Image Classification

I'm a Python programmer, but a beginner to image processing :) Apologies if this isn't a suitable question for the forum, happy to rewrite or move.

I want to create a supervised classifier to distinguish between the two images in this album (or more generally, with more training data, this scene containing some pavement for available parking, and this scene containing no pavement).

My question is about how to extract features, using Pillow or scikit-image, that would be appropriate for classification.

Right now, I have skeleton code for an SVM classifier:

data = []
classes = []
for imagefile in glob.glob('./img/training/*/*.bmp'):
data.append(extract_features(imagefile))
if 'nospace' in imagefile:
classes.append('nospace')
else:
classes.append('space')
clf = svm.SVC(gamma=0.001, C=100.)
clf.fit(data, classes)


And I have a very simple feature extraction method, which just returns a colour histogram for the image:

def extract_features(imagefile):
im = Image.open(imagefile)
width, height = im.size
im = im.crop((0, int(height * 0.4), width, int(height * 0.8)))
# Improve on just returning a colour histogram?
return im.histogram()


The problem is that this doesn't give great results - particularly if the car is nearly the same colour as the tarmac, as in my example album.

I looked at edge detection. This seems to be quite easy to do with Pillow:

im.filter(ImageFilter.FIND_EDGES)


But just passing this in to the classifier also doesn't give great results - I'm guessing because I should turn it from a matrix of pixels into something more meaningful?

Could anyone suggest a good approach for extracting features for this problem? I think ideally I want to detect "blobs", i.e. cars.

• Can you tell me what is the end goal ? is it to find if there is empty parking space on the pavement? – harshkn May 5 '17 at 8:54