예제 #1
0
	def similarity(self, pict):
		# distance of sizes
		#dim=sum(map(lambda (x,y):(x-y)**2, zip(self.size, pict.size)))
		#dim/=self.size[0]**2+self.size[1]**2
		msr=[]
		#dimensions=zip(self.size, pict.size)
		#widths=sorted(dimensions[0])
		#heights=sorted(dimensions[1])
		#msr.append(sqr(1.*widths[0]/widths[1]*heights[0]/heights[1]))
		#FIXME: hier irgendwo bleibts haengen, wenn ca. bilder
		# beim instanziieren ihre local copies nicht laden konnten
		dimcor = stats.pearson(self.size, pict.size)
		if dimcor:
			msr.append(dimcor)
		#hst=sum(map(lambda (x,y):(x-y)**2, zip(self.histogram, pict.histogram)))
		hstcor=measure.image_histograms(self, pict)
		if hstcor:
			msr.extend(hstcor)
		mood=measure.image_histmediandist(self, pict)
		if mood:
			msr.append(1.-mood)
		#colorful=measure.image_histrelcor(self, pict)
		#if colorful:
			#msr.extend(colorful)
		#dist = measure.image_hist_dist(self, pict)
		#if dist:
			#msr.append(1.-dist/255.)
		res = 1.
		#while len(msr)>0:
			#res *= msr.pop()
		return sum(msr)/len(msr)
예제 #2
0
	def compare(self, pict):
		sim=self.similarity(pict)
		if sim>.85:
			connect(self,pict,sim)
		print 'Similarity: {:2.3f}'.format(sim)
		print 'Color mood dist: {:2.3f}'.format(
			measure.image_histmediandist(self, pict))
		for p in [self, pict]:
			print '\tInfo:     \t{}'.format(p.info)
			print '\tNamespace:\t{}'.format(p.path)
			print '\tFilename: \t{}'.format(p.name)
			print '\tHistogram:\t{}'.format(p.hist)
			print '\tSources:\n\t\t',
			for source in p.sources:
				print source.name,
			print
예제 #3
0
파일: pyindx.py 프로젝트: JKatzwinkel/bash
	def similarity(self, pict):
		# distance of sizes
		#dim=sum(map(lambda (x,y):(x-y)**2, zip(self.size, pict.size)))
		#dim/=self.size[0]**2+self.size[1]**2
		msr=[]
		dimensions=zip(self.size, pict.size)
		widths=sorted(dimensions[0])
		heights=sorted(dimensions[1])
		msr.append(sqr(1.*widths[0]/widths[1]*heights[0]/heights[1]))
		#hst=sum(map(lambda (x,y):(x-y)**2, zip(self.histogram, pict.histogram)))
		hstcor=measure.image_histograms(self, pict)
		msr.extend(hstcor)
		mood=measure.image_histmediandist(self, pict)
		msr.append(1-mood)
		#colorful=measure.image_histrelcor(self, pict)
		#msr.extend(colorful)
		return sum(msr)/len(msr)