All pastes #1718572 Raw Edit

Diff

public text v1 · immutable
#1718572 ·published 2009-12-17 19:42 UTC
rendered paste body
--- snap2.py	2009-12-17 20:13:52.000000000 +0100+++ snap3.py	2009-12-17 20:26:21.000000000 +0100@@ -34,8 +34,8 @@ a = numpy.asarray(i) # a is readonly i = Image.fromarray(a) -cx=np.sum(f*np.arange(f.shape[0])[:,np.newaxis])/np.sum(f)-cy=np.sum(f*np.arange(f.shape[1])[np.newaxis,:])/np.sum(f)+cy=np.sum(f*np.arange(f.shape[0])[:,np.newaxis])/np.sum(f)+cx=np.sum(f*np.arange(f.shape[1])[np.newaxis,:])/np.sum(f) """  def filter(a,axis):@@ -43,15 +43,15 @@ #numpy.apply_over_axes(func, a, axes) oa=numpy.asarray(im) a=numpy.copy(oa)-fuzz=40-rgb=numpy.array([230,160,134])+fuzz=10+rgb=numpy.array([121,47,46]) b=numpy.all(numpy.abs(a-rgb[numpy.newaxis,numpy.newaxis,:])<fuzz, axis=-1) #mask with red a[b]=[255,0,0] nim = image.fromarray(a) #calculate centrepoint and draw a mark-cx=numpy.sum(b*numpy.arange(b.shape[0])[:,numpy.newaxis])/numpy.sum(b)-cy=numpy.sum(b*numpy.arange(b.shape[1])[numpy.newaxis,:])/numpy.sum(b)+cy=numpy.sum(b*numpy.arange(b.shape[0])[:,numpy.newaxis])/numpy.sum(b)+cx=numpy.sum(b*numpy.arange(b.shape[1])[numpy.newaxis,:])/numpy.sum(b) drw=ImageDraw.Draw(nim) drw.line([cx-16,cy,cx+16,cy],fill=255) drw.line([cx,cy-16,cx,cy+16],fill=255)