Ejemplo n.º 1
0
 def run(self, ips, imgs, para = None):
     old = ips.size
     shp = (para['w'], para['h'])
     chns = ips.get_nchannels()
     if chns>1:shp = (shp[1], shp[0], chns)
     
     if para['hor'] == 'left':c=0
     if para['ver'] == 'top':r=0
     if para['hor'] == 'center':c=(shp[1]-old[1])/2
     if para['ver'] == 'center':r=(shp[0]-old[0])/2
     if para['hor'] == 'right':c=shp[1]-old[1]
     if para['ver'] == 'bottom':r=shp[0]-old[0]
         
     if ips.is3d:
         s = list(imgs.shape)
         s[1], s[2] = shp[0], shp[1]
         rst = np.zeros(s, dtype=ips.dtype)
         for i in range(len(imgs)):
             IPy.curapp.set_progress(round(i*100.0/len(imgs)))
             bliter.blit(rst[i], imgs[i], c, r)
     else:
         rst = []
         for i in range(len(imgs)):
             IPy.curapp.set_progress(round(i*100.0/len(imgs)))
             rst.append(np.zeros(shp, ips.dtype))
             bliter.blit(rst[-1], imgs[i], c, r)
     IPy.curapp.set_progress(0)
     ips.roi = None
     ips.set_imgs(rst)
Ejemplo n.º 2
0
    def mouse_up(self, ips, x, y, btn, **key):
        if self.moving == True:
            self.moving = False
            ci = ClipBoardManager.img
            img = ips.get_img()
            #ips.roi.draged(ci.shape[1]/2,ci.shape[0]/2, ips.size[1]/2, ips.size[0]/2, True)
            #ips.roi = IPy.clipboard[1].affine(np.eye(2), ((np.array(ips.size)-ci.shape[:2])[::-1]/2))
            x, y = (np.array(ips.size) - ci.shape[:2]) / 2 + (self.cy, self.cx)
            bliter.blit(img, ci, y, x)

            ips.reset(True)
            ips.update = True
Ejemplo n.º 3
0
 def run(self, ips, imgs, para=None):
     if ClipBoardManager.img == None: return
     ips.snapshot()
     ips.roi = ClipBoardManager.roi
     ci = ClipBoardManager.img
     img = ips.get_img()
     #ips.roi.draged(ci.shape[1]/2,ci.shape[0]/2, ips.size[1]/2, ips.size[0]/2, True)
     ips.roi = ClipBoardManager.roi.affine(
         np.eye(2), ((np.array(ips.size) - ci.shape[:2])[::-1] / 2))
     x, y = (np.array(ips.size) - ci.shape[:2]) / 2
     bliter.blit(img, ci, y, x)
     ips.reset(True)
     ips.tool = PasteMove()
Ejemplo n.º 4
0
    def run(self, ips, imgs, para=None):
        ips1 = WindowsManager.get(para['img1']).ips
        ips2 = WindowsManager.get(para['img2']).ips

        sl1, sl2 = ips1.get_nslices(), ips2.get_nslices()
        cn1, cn2 = ips1.get_nchannels(), ips2.get_nchannels()
        if ips1.dtype != ips2.dtype:
            IPy.alert('Two stack must be equal dtype!')
            return
        elif sl1 > 1 and sl2 > 1 and sl1 != sl2:
            IPy.alert('Two stack must have equal slices!')
            return
        elif cn1 > 1 and cn2 > 1 and cn1 != cn2:
            IPy.alert('Two stack must have equal chanels!')
            return

        w, h = ips1.size, ips2.size
        w, h = min(w[0], h[0]), min(w[1], h[1])
        if sl1 == 1:
            bliter.blit(ips1.get_img(), ips2.get_img(), mode=para['op'])
        elif sl1 > 1 and sl2 == 1:
            for i in range(sl1):
                IPy.set_progress(round(i * 100.0 / sl1))
                bliter.blit(ips1.imgs[i], ips2.get_img(), mode=para['op'])
        elif sl1 > 1 and sl2 > 1:
            for i in range(sl1):
                IPy.set_progress(round(i * 100.0 / sl1))
                bliter.blit(ips1.imgs[i], ips2.imgs[i], mode=para['op'])
        IPy.set_progress(0)
        ips1.update = 'pix'