def measure(self,line):
h,w = line.shape
smoothed = filters.gaussian_filter(line,(h*0.5,h*self.smoothness),mode='constant')
smoothed += 0.001*filters.uniform_filter(smoothed,(h*0.5,w),mode='constant')
self.shape = (h,w)
a = argmax(smoothed,axis=0)
a = filters.gaussian_filter(a,h*self.extra)
self.center = array(a,'i')
deltas = abs(arange(h)[:,newaxis]-self.center[newaxis,:])
self.mad = mean(deltas[line!=0])
self.r = int(1+self.range*self.mad)
if self.debug:
figure("center")
imshow(line,cmap=cm.gray)
plot(self.center)
ginput(1,1000)
评论列表
文章目录