2
$\begingroup$

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.

$\endgroup$
1
  • $\begingroup$ Can you tell me what is the end goal ? is it to find if there is empty parking space on the pavement? $\endgroup$
    – harshkn
    May 5, 2017 at 8:54

2 Answers 2

2
$\begingroup$

You are just using the histogram as your features, yet your image contains very slight differences. This is not discriminative enough for SVM, you should focus on better features. In this case, you might be better of with subtraction, change detection and etc.

$\endgroup$
2
$\begingroup$

If you just need to find if the two images are different you don't need a classifier. Classifier is for detecting higher level of features. If you just need to know two images are different you could subtract image 1 and image 2 and threshold the image to convert into binary image. Do some morphological operation (erosion and dilation) which will result in blobs based on which you could tell whether the two images are different or not. I don't see why you need a classifier here. Hope this helps you.

$\endgroup$

Your Answer

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

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