# SVM for Image Segmentation?

I turn to this forum for advice with the following problem. If you could please shed some light on any aspect of this question I'd be very grateful.

Problem decription:
I'm trying to use an SVM to segment a grayscale image of a puncture in polymer (original res. 1280x1024, can't post, no reputation :)

Now, I know this isn't probably the most conventional way to approach this problem, but still I'd like to try whether it is possible in any way.

My work so far:
I think of the segmentation problem as follows: classify a given pixel based on its value and neighborhood pixel values, i.e. determine whether pixel belongs to the foreground (puncture) or background (anything other than puncture).

I labeled this image using GIMP (for the SVM training purposes, i.e. marked the location of the puncture, i.e. each pixel is given a class (1 - puncture, -1 - background)) and tried to extract some simple features:

1. central pixel value + neighborhood pixel values with varying size of neighborhood
2. central pixel value + differences between central pixel value and neighborhood pixel values
3. central pixel value + 2D FFT spectrum of the neighborhood (amplitude and phase components)
4. standard deviation of the neighborhood

Note that I varied neighborhood size from 3x3 = 9 dimensions to 11x11 = 121 dimensions. I couldn't go higher (I use MATLAB for this, i'm getting out of memory errors). None of these were found sufficiently discriminatory. (I used PCA to inspect, calculated between-class distance of centroids and their respective class covariance matrices).

Soo, at last, to my question:
Could you think of any useful features to use for this task? (I was thinking some measures of homogeneity of the neighborhood would be helpful, since inside of the puncture is more or less uniform in brightness, but haven't found any. Also maybe some texture features would be helpful, but who knows.)

• I'm not an image processing person, but perhaps you could try running a sobel or canny operator on the image to detect edges first? Also, how familiar are you with SVM? I ask because it is not a technique that generally works well 'out of the box' it requires some parameter tuning, kernel selection and feature scaling, etc.. If you aren't familiar with that and are getting poor results it could be due to that and not necessarily to the data or features themselves. You may already be doing that of course. – karenu Apr 27 '12 at 13:45
• When I further looked into it, I think I'll use some kind of homogeneity measure. I don't know whole lotta about SVM, but I know a bit. One of the reasons why the neighborhood pixels aren't discriminatory enough is the fact that the neighborhood size is too small given the resolution 1280x1024. So I undersampled the image to 1/4th of it's resolution 320x256 and used 5x5 neighborhood, which seems to capture enough info about the center pixel's surroundings. Also the memory requirements went rapidly down after undersampling. Anyway thanks for the advice. – Jacob Apr 28 '12 at 14:44
• If you haven't seen it, this practical guide to SVM is very useful: csie.ntu.edu.tw/~cjlin/papers/guide/guide.pdf – karenu Apr 28 '12 at 23:46
• Yeah I'm reading it now :). I use their implementation libsvm. I discovered that I was using one-class svm and instead I should be using C-SVC. So this time I achieved approx. 75% accuracy using 7x7 neighborhood, central pixel value + amplitude and phase spectra as features (i.e. 99 dimensions) (C-SVC, kernel: RBF, not much of a parameter tunning) – Jacob Apr 30 '12 at 7:41
• Parameter tuning makes a big difference - SVM is very sensitive to the parameters. In experiments I've run the parameters can change the results from 60% accuracy or less to > 99%. In running a grid search for parameters make sure you vary them in orders of magnitude from very small to large. So for C try something like 0.000001 0.00001, 0.0001, 0.001, 0.01, 0.1, 1, 10. It's similar for gamma for the RBF kernel. A common mistake is trying say 1,2,3,4,5..etc for C when what you need is 0.00001. – karenu Apr 30 '12 at 13:35