def run(self, ips, imgs, para=None):
     cmap = ColorManager.get(para['LUT'])
     imglut = color_code(imgs[para['Start image'] - 1:para['End image']],
                         cmap)
     self.app.show_img([imglut], 'Color-coded %s' % ips.title)
     if para['Creatbar']:
         cmapshow = np.ones([32, 256, 3]) * cmap
         self.app.show_img([cmapshow.astype('uint8')], 'Color bar')
Beispiel #2
0
	def on_cmapsel(self, event):
		key = self.cmapsel.GetValue()
		lut = ColorManager.get(key)
		n = self.spn_num.GetValue()+1
		idx = np.linspace(0, 255, n).astype(int)
		self.cs = list(lut[idx]) + [(128,128,128)]*(16-n)
		for btn, c in zip(self.btns, self.cs):
			btn.SetBackgroundColour(c)

		ips = self.app.get_img()
		if ips is None: return
		newlut = lut*0
		newlut[:n] = lut[idx]
		ips.lut = newlut
		ips.update()
Beispiel #3
0
 def run(self, ips, imgs, para=None):
     shp = ips.img.shape[:2]
     imgs = [
         np.zeros(shp, dtype=np.uint8)
         for i in range([1, len(imgs)][para['slice']])
     ]
     newips = ImagePlus(imgs, ips.title + '-mark')
     newips.back = ips
     idx = [
         'None', 'Max', 'Min', 'Mask', '2-8mix', '4-6mix', '5-5mix',
         '6-4mix', '8-2mix'
     ]
     modes = ['set', 'max', 'min', 'msk', 0.2, 0.4, 0.5, 0.6, 0.8]
     newips.lut = ColorManager.get(para['cm'])
     newips.chan_mode = modes[idx.index(para['mode'])]
     #newips.range = (0, para['n'])
     IPy.show_ips(newips)
 def run(self, tps, snap, data, para=None):
     rs = data[
         para['rs']] * para['s'] if para['rs'] != 'None' else para['s']
     cs = data[para[
         'cs']] if para['cs'] != 'None' else '#%.2x%.2x%.2x' % para['c']
     cm = ColorManager.get(para['cm']) / 255.0
     cm = None if para['cs'] == 'None' else colors.ListedColormap(cm, N=256)
     plt = self.app.show_plot(para['title'])
     data.plot.scatter(x=para['x'],
                       y=para['y'],
                       s=rs,
                       c=cs,
                       alpha=para['alpha'],
                       cmap=cm,
                       grid=para['grid'],
                       title=para['title'],
                       ax=plt.add_subplot())
     plt.Show()
Beispiel #5
0
    def run(self, ips, snap, img, para = None):
        strc = generate_binary_structure(2, 1 if para['con']=='4-connect' else 2)

        lab, n = label(snap, strc, output=np.uint32)
        idx = (np.zeros(n+1)).astype(np.uint8)
        ls = regionprops(lab)
        
        if para['pro'] == 'area': ps = [i.area for i in ls]
        if para['pro'] == 'perimeter': ps = [i.perimeter for i in ls]
        if para['pro'] == 'solid': ps = [i.solidity for i in ls]
        if para['pro'] == 'eccentricity': ps = [i.major_axis_length/i.minor_axis_length for i in ls]

        ps = np.array(ps)
        if ps.max() != ps.min():
            ps = (ps - ps.min()) / (ps.max() - ps.min())
        else: ps = ps / ps.max()
        idx[1:] = ps * 245 + 10
        img[:] = idx[lab]
        ips.lut = ColorManager.get(para['cm'])
Beispiel #6
0
 def run(self, tps, snap, data, para=None):
     pts = np.array(data[[para['x'], para['y'], para['z']]])
     rs = data[para['rs']] * para['r'] if para['rs'] != 'None' else [
         para['r']
     ] * len(pts)
     cm = ColorManager.get(para['cm']) / 255.0
     clip = lambda x: (x - x.min()) / (x.max() - x.min()) * 255
     if para['cs'] == 'None': cs = [np.array(para['c']) / 255.0] * len(pts)
     else: cs = cm[clip(data[para['cs']]).astype(np.uint8)]
     vts, fs, ns, cs = myvi.build_balls(pts.astype(np.float32), list(rs),
                                        cs)
     self.frame.viewer.add_surf_asyn('ball', vts, fs, ns, cs)
     if para['cube']:
         p1 = data[[para['x'], para['y'], para['z']]].min(axis=0)
         p2 = data[[para['x'], para['y'], para['z']]].max(axis=0)
         vts, fs, ns, cs = myvi.build_cube(p1, p2)
         self.frame.viewer.add_surf_asyn('cube',
                                         vts,
                                         fs,
                                         ns,
                                         cs,
                                         mode='grid')
     self.frame.Raise()
     self.frame = None