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 8655839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:08:12+00:00 2026-06-12T15:08:12+00:00

I am having a hard time understanding what scipy.cluster.vq really does!! On Wikipedia it

  • 0

I am having a hard time understanding what scipy.cluster.vq really does!!

On Wikipedia it says Clustering can be used to divide a digital image into distinct regions for border detection or object recognition.
on other sites and books it says we can use clustering methods for clustering images for finding groups of similar images.
AS i am interested in image processing ,I really need to fully understand what clustering is .

So
Can anyone show me simple examples about using scipy.cluster.vq with images??

  • 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-06-12T15:08:13+00:00Added an answer on June 12, 2026 at 3:08 pm

    The kind of clustering performed by scipy.cluster.vq is definitely of the latter (groups of similar images) variety.

    The only clustering algorithm implemented in scipy.cluster.vq is the K-Means algorithm, which typically treats input data as points in n-dimensional euclidean space, and attempts to divide that space so that new, incoming data can be summarized by saying “example x is most like centroid y”. Centroids can be thought of as prototypical examples of the input data. Vector quantization leads to concise, or compressed representations because, instead of remembering all 100 pixels of each new image we see, we can remember a single integer which points at the prototypical example that the new image is most like.

    If you had many small grayscale images:

    >>> import numpy as np
    >>> images = np.random.random_sample((100,10,10))
    

    So, we’ve got 100 10×10 pixel images. Let’s assume they already all have similar brightness and contrast. The scipy kmeans implementation expects flat vectors:

    >>> images = images.reshape((100,100))
    >>> images.shape
    (100,100)
    

    Now, let’s train the K-Means algorithm so that any new incoming image can be assigned to one of 10 clusters:

    >>> from scipy.cluster.vq import kmeans, vq
    >>> codebook,distortion = kmeans(images,10)
    

    Finally, let’s say we have five new images we’d like to assign to one of the ten clusters:

    >>> newimages = np.random.random_samples((5,10,10))
    >>> clusters = vq(newimages.reshape((5,100)),codebook)
    

    clusters will contain the integer index of the best matching centroid for each of the five examples.

    This is kind of a toy example, and won’t yield great results unless the objects of interest in the images you’re working with are all centered. Since objects of interest might appear anywhere in larger images, it’s typical to learn centroids for smaller image “patches”, and then convolve them (compare them at many different locations) with larger images to promote translation-invariance.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a really hard time understanding delegates and object inheritance (if I may
I'm having a hard time understanding why I can't assign a return value from
I am having a hard time understanding attr_accessor in Ruby . Can someone explain
Having hard time understanding classes and why I can't access certain object. How can
I am having a hard time understanding what Storable does. I know that it
I am having a hard time understanding Static scope in Javascript. Can anyone please
I am having a hard time understanding what hook_theme() does. My understanding is that
I am having a hard time understanding this and hopefully someone can correct me
I am using LINQ and am having a hard time understanding how I can
I'm having a hard time understanding modules in Yii. Can someone explain to me

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.