def triangles(im, points=[], contour=None, fib_step=None, isblank=False, queue=None): ''' Divides the image into triangular regions. Arguments: im: the image to work with. points: a set of prefered points to use instead of provided option. Usually cached points from previous itterations. countour: the color of the contour to use. By default the contour is set to 30 intensity darker than the color in the current region for contrast. mesh: if not none, denotes the chunck size that the finonacci mesh will be used, but only if points is [] lloyd: when True, a lloyd mesh will be used, but only if points is [] isblank: when True, the image will just have the contour of the mesh overlayed when filled. This flag treats the image as blank. if contour is set, the overlay will have the contour=contour, else, 0 (black) queue: when not None, the image is sent to the message queue instead of being returned. This is particulal handy when running concurently. ''' # copy the image, to prevent inplace operations img = im.copy() if len(points) != 0: # we got free points to work with pass elif fib_step: # use fibonacci mesh points = fib_mesh(img, fib_step) else: # use random points points = random_pts(img) # create Delaunay triangles tri = Delaunay(points) # get all the vertices of the triangles to sent them to be filled v = [points[x] for x in tri.simplices] # fill all the vertices. fill(img, v, contour=contour, isblank=isblank) # if running concurently send the items to the queue if queue: label = 'Triangles: ' label += 'Fibonacci-Steps: {} '.format( fib_step) if fib_step is not None else '' label += 'Random-Steps: {} '.format(True) if fib_step is None else '' queue.put((label, img)) else: # return return the image instead. return img
def pydoc(op, children=()): doc = "\n\n".join([fill(p.text(), 0) for p in op.query["doc"]]) for ch in children: doc += "\n\n " + pythonize(ch["@name"]) + " -- " + str(ch["@label"]) ch_descs ="\n\n".join([fill(p.text(), 4) for p in ch.query["doc"]]) if ch_descs: doc += "\n\n" + ch_descs return doc
def pydoc(op, children=()): doc = "\n\n".join([fill(p.text(), 0) for p in op.query["doc"]]) for ch in children: doc += "\n\n " + pythonize(ch["@name"]) + " -- " + str(ch["@label"]) ch_descs = "\n\n".join([fill(p.text(), 4) for p in ch.query["doc"]]) if ch_descs: doc += "\n\n" + ch_descs return doc
def docstring(self): s = "\n\n".join([fill(d, 2) for d in [self.description] + self.docs]) for f in self.fields: if f.docs: s += "\n\n" + "\n\n".join([fill(f.docs[0], 4, f.name)] + [fill(d, 4) for d in f.docs[1:]]) if self.responses: s += "\n\nValid responses: " for r in self.responses: s += r.name + " " return s
def pentagons(im, points=[], contour=None, fib_step=None, lloyd_cells=None, isblank=False, queue=None): ''' Divides the image into hexagon/pentagon regions Arguments: im: the image to work with. points: a set of prefered points to use instead of provided option. Usually cached points from previous itterations. countour: the color of the contour to use. By default the contour is set to 30 intensity darker than the color in the current region for contrast. mesh: when True, a finonacci mesh will be used, but only if points is [] lloyd: when True, a lloyd mesh will be used, but only if points is [] isblank: when True, the image will just have the contour of the mesh overlayed when filled. This flag treats the image as blank. if contour is set, the overlay will have the contour=contour, else, 0 (black) queue: when not None, the image is sent to the message queue instead of being returned. This is particulal handy when running concurently. ''' # copy the image, to prevent inplace operations img = im.copy() if len(points) != 0: # we got free points to work with pass elif fib_step: # use fibonacci mesh points = fib_mesh(img, fib_step) elif lloyd_cells: # use lloyd mesh points = lloyd_mesh(img, lloyd_cells) else: # use random points points = random_pts(img) # create the voronoi dragrams vor = Voronoi(points) # get all the vertices ready and sent them to be filled or contoured v = [] # get all the vertices of this region and # check if the current region isn't reaching towards infinity for region in vor.regions: if not -1 in region and len(region) > 0: v.append(vor.vertices[region]) # fill all regions at once fill(img, v, contour=contour, isblank=isblank) # if running concurently send the items to the queue if queue: label = 'Pentagons: ' label += 'Fibonacci-Steps: {} '.format( fib_step) if fib_step is not None else '' label += 'Lloyd-Cell-Size: {} '.format( lloyd_cells) if lloyd_cells is not None else '' label += 'Random-Steps: {} '.format( True) if fib_step is None and lloyd_cells is None else '' queue.put((label, img)) else: # return them instead. return img
parL = np.empty(numBins, np.dtype('float64')) parLerr = np.empty(numBins, np.dtype('float64')) for ibin in range(0, numBins): hists.append( r.TH1D("tmp_" + str(ibin), "tmp_" + str(ibin), 400, 0., 2.)) energies.append(int(ibin * energyBin)) energies.append(maxEnergy) if numBins > len(ut.colors()): for i in range(0, numBins - len(ut.colors())): ut.colors().append(ut.colors()[i]) ut.alpha().append(0.3) ut.lines().append(ut.lines()[i]) ut.width().append(ut.width()[i]) ut.fill().append(3001) leg = r.TLegend(0.25, 0.55, 0.3, 0.85) leg.SetTextFont(132) leg.SetTextSize(0.05) leg.SetFillColor(0) leg.SetFillStyle(0) ifile = "/eos/user/c/cneubuse/miniCalo2/pred/stage" + str(st) + "/out.root" miX = 0.8 maX = 1.18 # if args.stage>1: # miX=0.8 # maX=1.2