Example #1
0
 def draw_pixs(self, img, xs, ys, color=None):
     mskx = (xs >= 0) * (xs < img.shape[1])
     msky = (ys >= 0) * (ys < img.shape[0])
     msk = mskx * msky
     if color == None: color = ColorManager.get_front()
     color = match_color(img, color)
     img[ys[msk], xs[msk]] = color
Example #2
0
    def run(self, para=None):

        plus = IPy.get_ips()
        if plus == None:
            img = np.ones(
                (30, 1), dtype=np.uint8) * np.arange(256, dtype=np.uint8)
            ips = ImagePlus([img])
            frame = CanvasFrame(IPy.curapp)
            frame.set_ips(ips)
            ips.lut = ColorManager.get_lut(self.title)
            frame.Show()
        elif plus.chanels != 1:
            IPy.alert('RGB image do not surport Lookup table!')
            return
        else:
            plus.lut = ColorManager.get_lut(self.title)
            plus.update = 'pix'
Example #3
0
 def mouse_down(self, ips, x, y, btn, **key):
     ips.snapshot()
     msk = floodfill(ips.get_img(), x, y, self.para['tor'],
                     self.para['con'] == '8-connect')
     #plt.imshow(msk)
     #plt.show()
     color = ColorManager.get_front()
     if ips.get_nchannels() == 1: color = np.mean(color)
     ips.get_img()[msk] = color
     ips.update = 'pix'
Example #4
0
 def draw_point(self, img, x, y, r=1, color=None):
     shape = img.shape
     if x < 0 or y < 0 or x >= shape[1] or y >= shape[0]: return
     if color == None: color = ColorManager.get_front()
     color = match_color(img, color)
     if r == 1: img[y, x] = color
     n = int(r)
     xs, ys = np.mgrid[-n:n + 1, -n:n + 1]
     msk = np.sqrt(xs**2 + ys**2) < r
     x, y = np.round((x, y)).astype(np.int)
     self.draw_pixs(img, xs[msk] + x, ys[msk] + y, color)
Example #5
0
 def __init__(self, imgs, title=None, is3d=False):
     self.set_imgs(imgs)
     self.set_title(title)
     self.snap = None
     self.cur = 0
     self.update = False
     self.scrchanged = False
     self.roi = None
     self.mark = None
     self.msk = None
     self.mskmode = None
     self.lut = ColorManager.get_lut('grays')
     self.tool = None
Example #6
0
 def run(self, ips, snap, img, para=None):
     img[ips.get_msk('out')] = ColorManager.get_back(snap.ndim == 2)
Example #7
0
 def run(self, ips, snap, img, para=None):
     img[ips.get_msk()] = ColorManager.get_front(snap.ndim == 2)
Example #8
0
 def fill_polygon(self, pg, img, holes=[], color=None):
     if color == None: color = ColorManager.get_front()
     color = match_color(img, color)
     pgs = [pg] + holes
     polygonfill.fill(pgs, img, color)
Example #9
0
 def mouse_down(self, ips, x, y, btn, **key):
     if btn == 1: ColorManager.set_front(ips.get_img()[int(y), int(x)])
     if btn == 3: ColorManager.set_back(ips.get_img()[int(y), int(x)])
     print(ips.get_img()[int(y), int(x)])
     print(ColorManager.get_front())
Example #10
0
 def config(self):
     ColorManager.set_front(self.para['front'])
     ColorManager.set_back(self.para['back'])