Spectral Clustering, Image Segmentation and Eigenvectors

后端 未结 1 1372
旧时难觅i
旧时难觅i 2021-02-06 15:54

Based on the book Computer Vision a Modern Approach page 425, I attempted to use eigenvectors for image segmentation.

http://dl.dropbox.com/u/1570604/tmp/comp-vis-moder

相关标签:
1条回答
  • 2021-02-06 16:32

    I've just tried the algorithm in Mathematica, it works fine on your image, so there must be a subtle bug in your code.

    This part:

    V,D = np.linalg.eig(A)
    V = np.real(V)
    res = n_max(V,1) # take largest 
    idx = res[0][1][0] 
    a = np.real(D[idx]) # look at corresp eigv
    

    looks strange: all linear algebra packages I know return the eigenvalues/eigenvectors sorted, so you'd just take the first eigenvector in the list. That's the one that corresponds to the highest eigenvalue. Try plotting the eigenvalues list to confirm that.

    Also, where did you get the fixed threshold from? Have you tried normalizing the image to display it?

    For what it's worth, the results I'm getting for the first 3 eigenvectors are:

    Eigenvector1 Eigenvector2 Eigenvector3

    This is the Mathematica code I use:

    pixels = Flatten[image];
    weights = Table[N[Exp[-(pixels[[i]] - pixels[[j]])^2]], {i, 1, 900}, {j, 1, 900}];
    eigenVectors = Eigenvectors[weights];
    ImageAdjust[Image[Partition[eigenVectors[[1]], 30]]]
    
    0 讨论(0)
提交回复
热议问题