Exemplo n.º 1
0
 def make_mark(self):
     a = self.para['ang'] / 180.0 * np.pi
     mark = {
         'type':
         'layer',
         'color': (0, 255, 0),
         'body': [{
             'type': 'circle',
             'fcolor': (255, 255, 255),
             'fill': True,
             'body': (self.para['ox'], self.para['oy'], 5)
         }, {
             'type': 'circle',
             'body': (self.para['ox'], self.para['oy'], 50)
         }, {
             'type':
             'circle',
             'fcolor': (255, 255, 255),
             'fill':
             True,
             'body': (self.para['ox'] + np.cos(a) * 50,
                      self.para['oy'] + np.sin(a) * 50, 3)
         }]
     }
     self.ips.mark = mark2shp(mark)
Exemplo n.º 2
0
    def make_mark(self, x, y):
        wins = self.para['win']
        rect = {
            'type': 'rectangle',
            'body': (x - wins, y - wins, wins * 2, wins * 2),
            'color': self.para['color']
        }
        mark = {'type': 'layer', 'body': [rect]}
        r = 2 if self.status == 'local_brush' else self.para['r'] / 2
        mark['body'].append({
            'type': 'circle',
            'body': (x, y, r),
            'color': self.para['color']
        })

        mark['body'].append({
            'type':
            'text',
            'body': (x - wins, y - wins,
                     'S:%s W:%s' % (self.para['ms'], self.para['win'])),
            'pt':
            False,
            'color':
            self.para['color']
        })
        return mark2shp(mark)
Exemplo n.º 3
0
 def make_mark(self):
     mark = {'type':'layer', 'body':[
         {'type':'rectangle', 'color':(0,255,0), 
         'body':(self.lt, self.tp, self.rt-self.lt, self.bm-self.tp)},
         {'type':'points', 'color':(0,255,0), 'body':[(self.lt, self.tp), 
         (self.lt, self.bm), (self.rt, self.tp), (self.rt, self.bm), 
         (self.lt, (self.tp+self.bm)/2), (self.rt, (self.tp+self.bm)/2),
         ((self.lt+self.rt)/2, self.tp), ((self.lt+self.rt)/2, self.bm)]}
     ]}
     self.ips.mark = mark2shp(mark)
Exemplo n.º 4
0
 def draw(self,ips):
     mark = {'type':'layers', 'body':{}}
     layer = {'type':'layer', 'body':[]}
     layer['body'].append({'type':'points', 'body':self.buf})
     if len(self.buf)>1:
         lines=route_through(ips, ips.img,[self.buf],self.para)
         lst=[]
         for line in lines:lst.append([(j,i) for i,j in line])
         layer['body'].append({'type':'lines', 'body':lst})
     mark['body'][0] = layer
     ips.mark = mark2shp(mark)
     ips.update()     
Exemplo n.º 5
0
 def run(self, ips, imgs, para=None):
     if not para['stack']: imgs = [ips.img]
     sli = ips.rect
     imgs = [i[sli].copy() for i in imgs]
     if ips.isarray: imgs = np.array(imgs)
     new = Image(imgs, ips.name + '-duplicate')
     if not ips.roi is None:
         new.roi = ROI(mark2shp(ips.roi.to_mark()))
         offset(new.roi, new.roi.box[0] * -1, new.roi.box[1] * -1)
         new.roi.dirty = True
     if not ips.back is None and not ips.back.imgs is None:
         back = [i[sli].copy() for i in ips.back.imgs]
         if ips.isarray: back = np.array(back)
         back = Image(back, ips.back.name + '-duplicate')
         back.cn, back.rg, back.mode = ips.back.cn, ips.back.rg, ips.back.mode
         new.back, new.mode = back, ips.mode
         self.app.show_img(back)
     self.app.show_img(new)
Exemplo n.º 6
0
 def run(self, ips, imgs, para=None):
     with open(para['path']) as f:
         ips.mark = mark2shp(json.loads(f.read()))