Beispiel #1
0
    def run(self, ips, imgs, para=None):
        idx = ['red', 'green', 'blue']
        imr, img, imb = [WindowsManager.get(para[i]).ips for i in idx]
        sr, sg, sb = [i.get_nslices() for i in [imr, img, imb]]

        if imr.imgtype != '8-bit' or img.imgtype != '8-bit' or imb.imgtype != '8-bit':
            IPy.alert('must be three 8-bit image!')
            return
        if imr.size != img.size or img.size != imb.size or sr != sg or sg != sb:
            IPy.alert(
                'three image must be in same size and have the same slices!')
            return

        rgb = []
        w, h = imr.size
        rgbs = zip(imr.imgs, img.imgs, imb.imgs)
        for i in range(sr):
            IPy.curapp.set_progress(round((i + 1) * 100.0 / sr))
            img = np.zeros((w, h, 3), dtype=np.uint8)
            for j in (0, 1, 2):
                img[:, :, j] = rgbs[i][j]
            rgb.append(img)
        IPy.curapp.set_progress(0)
        ip = ImagePlus(rgb, 'rgb-merge')
        frame = CanvasFrame(IPy.curapp)
        frame.set_ips(ip)
        frame.Show()
        if self.para['destory']:
            for title in [para[i] for i in idx]:
                WindowsManager.close(title)
Beispiel #2
0
 def run(self, ips, imgs, para=None):
     r, g, b = [], [], []
     for i, n in zip(imgs, range(ips.get_nslices())):
         IPy.curapp.set_progress(round((n + 1) * 100.0 / len(imgs)))
         for c, ci in zip((r, g, b), (0, 1, 2)):
             if self.para['copy']: c.append(i[:, :, ci].copy())
             else: c.append(i[:, :, ci])
     IPy.curapp.set_progress(0)
     for im, tl in zip([r, g, b], ['red', 'green', 'blue']):
         ip = ImagePlus(im, ips.title + '-' + tl)
         frame = CanvasFrame(IPy.curapp)
         frame.set_ips(ip)
         frame.Show()
     if self.para['destory']:
         WindowsManager.close(ips.title)
 def run(self, para=None):
     if para['name'] == 'All':
         for i in WindowsManager.get_titles():
             WindowsManager.close(i)
     else:
         WindowsManager.close(para['name'])