title: How to automatically cluster my dataset images into different groups based on local features or global using python or OpenCV?
body: <p>I have a dataset of images , and i want to group my images into different groups based on content. What i have tried till now is find median of images and thought to group them into different clusters based on median values , How can i do that? This is what i have tried till now. How can i do cluster my images into groups? I did Google out many things on clustering, But it showed results on clustering based on colors rather than clustering images into groups.Can anyone provide me with informative answers?Can i automatically cluster my dataset into groups based on median or some other technique?</p>
  
  <pre><code>from PIL import Image
  import numpy as np
  import os
  Median=[]
  k=[]
  def get_imlist(path):       
      return [os.path.join(path,f) for f in os.listdir(path) if f.endswith('.jpg')]
  
  path='D:/Images/dataset'
  imlist= get_imlist(path)
  for file in imlist:
      head,tail=os.path.split(file)
      im=np.array(Image.open(file).convert('L'))
      m=np.median(im)
      M=[m,tail]
      print '.'
      Median.append(M)
  Results=sorted(Median, key=lambda median: median[0])
  print Results
  </code></pre>