Skip to content

Instantly share code, notes, and snippets.

@dbuscombe-usgs
Last active December 20, 2015 06:19
Show Gist options
  • Save dbuscombe-usgs/6085362 to your computer and use it in GitHub Desktop.
Save dbuscombe-usgs/6085362 to your computer and use it in GitHub Desktop.
Auto classify images part 2. Compile a list of images, and carry out a cluster analysis
imlist=[]
for infile in glob.glob( os.path.join(path, '*.jpg') ):
imlist.append(infile)
imlist=np.sort(imlist)
features = np.zeros([len(imlist),512])
for i,f in enumerate(imlist):
im = np.array(Image.open(f))
h, edges = np.histogramdd(im.reshape(-1,3),8,normed=True, range=[(0,255),(0,255),(0,255)])
features[i] = h.flatten()
import hcluster
tree = hcluster(features)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment