예제 #1
0
 def _process(self, element, key=None):
     paths = []
     for path in element.split():
         if len(path) < self.p.minimum_size:
             continue
         for p in split_path(path):
             if len(p) > self.p.minimum_size:
                 paths.append(p)
     return element.clone(paths)
예제 #2
0
 def _process(self, element, key=None):
     sampling = self._get_sampling(element, 0, 1)
     (x_range, y_range), (xvals, yvals), (width, height), (xtype, ytype) = sampling
     (x0, x1), (y0, y1) = x_range, y_range
     img = Image.new('L', (width, height), 0)
     draw = ImageDraw.Draw(img)
     for poly in element.split():
         poly = poly.reindex(vdims=[])
         for p in split_path(poly):
             xs, ys = (p.values if pd else p).T
             xs = ((xs - x0) / (x1-x0) * width)
             ys = ((ys - y0) / (y1-y0) * height)
             draw.polygon(list(zip(xs, ys)), outline=1, fill=1)
     img = np.array(img).astype('bool')
     return hv.Image((xvals, yvals, img), element.kdims)