Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6171813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:16:54+00:00 2026-05-23T23:16:54+00:00

Based on the book Computer Vision a Modern Approach page 425, I attempted to

  • 0

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-modern-segment.pdf

The author mentions that image pixel affinites can be captured in matrix A. Then we can maximize w^T A w product where w’s are weights. After some algebra one obtains Aw = \lambda w, finding w is like finding eigenvectors. Then finding the best cluster is finding the eigenvalue with largest eigenvector, the values inside that eigenvector are cluster membership values. I wrote this code

import matplotlib.pyplot as plt
import numpy as np

Img = plt.imread("twoObj.jpg")
(n,dummy) = Img.shape
Img2 = Img.flatten()
(nn,) = Img2.shape

A = np.zeros((nn,nn))

for i in range(nn):
    for j in range(nn):
        N=Img2[i]-Img2[j];
        A[i,j]=np.exp(-(N**2))

V,D = np.linalg.eig(A)
V = np.real(V)
a = np.real(D[1])

threshold = 1e-10 # filter
a = np.reshape(a, (n,n))
Img[a<threshold] = 255
plt.imshow(Img)
plt.show()

The image

enter image description here

Best result I could get from this is below. I have a feeling the results can be better.

The eigenvalues are sorted from largest to smallest in Numpy, I tried the first one, that did not work, then I tried the second one for the results seen below. Threshold value was chosen by trial and error. Any ideas on how this algorithm can be improved?

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T23:16:55+00:00Added an answer on May 23, 2026 at 11:16 pm

    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
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Based on chapter 5 (Generalized Functors) from the book Modern C++ Design, I'm trying
I would like to use form-based authentication as outlined in the book JavaServer Faces
Based on this post http://www.adam-bien.com/roller/abien/entry/ejb_3_1_killed_the I use in my app @Named @Stateless bean for
Based on the Pro Git book by Scott Chacon on page 9, to install
I've build my own basic blog-tool with Rails 3.1 based upon http://ruby.railstutorial.org/ruby-on-rails-tutorial-book and with
Basically I want the books to be text book based, ie, author discusses the
I'm currently working through some exercises in a c++ book, which uses text based
Based on the book , pp338 #include <iostream> #include <vector> #include <string> #include <ostream>
How good is this book for learning algorithm creation, based on experiences ?
I am learning CoreData from a book based in iOS4, so, implementing the example

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.