Exemple #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)
Exemple #2
0
	def get_distances(self, other):
		distances=[]
		for p in self.members:
			for q in other.members:
				dist = measures.image_hist_dist(p,q)
				for corr in measures.image_histograms(p,q):
					dist *= 2-corr
				distances.append(dist)
		return distances
Exemple #3
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]))
		#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)