Ejemplo n.º 1
0
 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')
Ejemplo n.º 2
0
 def load(self, ips):
     self.slength = len(ips.imgs)
     self.para['End image'] = self.slength
     self.view = [(list, 'LUT', ColorManager.names(), str, 'LUT', ''),
                  (int, 'Start image', (1, self.slength), 0, 'Start image',
                   '1~%d' % self.slength),
                  (int, 'End image', (2, self.slength), 0, 'End image',
                   'start~%d' % self.slength),
                  (bool, 'Creatbar', 'Creat time color scale bar')]
     return True
Ejemplo n.º 3
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()
Ejemplo n.º 4
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)
Ejemplo n.º 5
0
 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()
Ejemplo n.º 6
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'])
Ejemplo n.º 7
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
Ejemplo n.º 8
0
from ..lookuptables_plg import LUT
from imagepy.app import ColorManager

plgs = [LUT(i, j) for i, j, _ in ColorManager.gets(tag='adv')]
Ejemplo n.º 9
0
	def __init__( self, parent, app=None):
		wx.Panel.__init__ ( self, parent, id = wx.ID_ANY, pos = wx.DefaultPosition, size = wx.Size(-1,-1), style = wx.TAB_TRAVERSAL )
		outsizer = wx.BoxSizer(wx.HORIZONTAL)
		sizer = wx.BoxSizer( wx.VERTICAL )
		sizer_color = wx.BoxSizer( wx.HORIZONTAL )
		self.app = app
		self.btns = []
		self.btn_make =  wx.Button( self, wx.ID_ANY, 'New Mark', wx.DefaultPosition, wx.DefaultSize, 0 )
		sizer_color.Add(self.btn_make, 0, wx.ALL, 2)
		for i in range(11):
			btn = wx.Button( self, wx.ID_ANY, str(i), wx.DefaultPosition, wx.DefaultSize, 0 )
			btn.SetMaxSize( wx.Size( 30,-1 ) )
			self.btns.append(btn)
			sizer_color.Add( btn, 0, wx.ALL, 2 )
		self.spn_num = wx.SpinCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.SP_ARROW_KEYS, 2, 15, 0 )
		self.spn_num.SetMaxSize(wx.Size(45, -1))
		sizer_color.Add( self.spn_num, 0, wx.ALL|wx.EXPAND, 2 )

		sizer.Add(sizer_color, 0, wx.ALL|wx.EXPAND, 0)

		sizer_other = wx.BoxSizer( wx.HORIZONTAL )

		self.btn_update =  wx.Button( self, wx.ID_ANY, 'Update', wx.DefaultPosition, wx.DefaultSize, 0 )
		sizer_other.Add( self.btn_update, 0, wx.ALL, 2)

		self.cmapsel = CMapSelCtrl(self)
		self.cmapsel.SetItems(ColorManager.gets(tag='base'))
		sizer_other.Add(self.cmapsel, 0, wx.ALL|wx.EXPAND, 2 )

		com_backChoices = [ u"No Background" ]
		self.com_back = wx.ComboBox( self, wx.ID_ANY, u"No Background", wx.DefaultPosition, wx.DefaultSize, com_backChoices, wx.CB_READONLY)
		self.com_back.SetSelection( 0 )
		sizer_other.Add( self.com_back, 1, wx.ALL|wx.EXPAND, 2 )
		
		com_modeChoices = [ u"None", u"Max", u"Min", u"Mask", u"2-8mix", u"4-6mix", u"5-5mix", u"6-4mix", u"8-2mix" ]
		self.com_mode = wx.ComboBox( self, wx.ID_ANY, u"Min", wx.DefaultPosition, wx.DefaultSize, com_modeChoices, wx.CB_READONLY )
		self.com_mode.SetSelection( 0 )
		sizer_other.Add( self.com_mode, 0, wx.ALL|wx.EXPAND, 2 )

		self.chk_hide = wx.CheckBox( self, wx.ID_ANY, u"Hide", wx.DefaultPosition, wx.DefaultSize, 0 )
		sizer_other.Add( self.chk_hide, 0, wx.ALIGN_CENTER|wx.ALL, 0 )

		sizer.Add(sizer_other, 0, wx.ALL|wx.EXPAND, 0)

		#sizer_tol = wx.GridSizer( 0, 3, 0, 0 )
		self.pens = []
		name = ['01.gif','03.gif','05.gif','10.gif','fill.gif']
		path = osp.abspath(osp.dirname(__file__))
		for i in (0,1,2,3,4):
			pen = wx.BitmapButton(self, wx.ID_ANY, make_bitmap(wx.Bitmap(osp.join(path, 'imgs', name[i]))),#make_bitmap(wx.Bitmap(data[1])), 
            wx.DefaultPosition, (30, 30), wx.BU_AUTODRAW|wx.RAISED_BORDER ) 
            #wx.Button( self, wx.ID_ANY, str(i), wx.DefaultPosition, wx.DefaultSize, 0 )
			pen.SetMaxSize( wx.Size( 30,-1 ) )
			self.pens.append( pen )
			sizer_color.Add( pen, 0, wx.ALL, 2 )

		outsizer.AddStretchSpacer(prop=1)
		#outsizer.Add(sizer_tol, 0, wx.ALL, 0)
		outsizer.Add(sizer, 0, wx.ALL, 0)
		outsizer.AddStretchSpacer(prop=1)

		self.SetSizer( outsizer )
		self.Layout()
		
		# Connect Events
		self.spn_num.Bind( wx.EVT_SPINCTRL, self.on_cmapsel )
		self.com_back.Bind(wx.EVT_COMBOBOX_DROPDOWN, self.on_items )
		self.cmapsel.Bind(wx.EVT_COMBOBOX,  self.on_cmapsel)
		self.com_back.Bind( wx.EVT_COMBOBOX, self.on_setback)
		self.com_mode.Bind( wx.EVT_COMBOBOX, self.on_mode)
		self.chk_hide.Bind( wx.EVT_CHECKBOX, self.on_mode)
		self.pens[-1].Bind( wx.EVT_BUTTON, self.on_fill)
		for i in self.btns: i.Bind(wx.EVT_BUTTON, self.on_color)
		for i in range(4): self.pens[i].Bind(wx.EVT_BUTTON, \
			lambda e, x=(1,3,5,10)[i]: self.on_pen(x))
		self.btn_make.Bind( wx.EVT_BUTTON, self.on_make)
Ejemplo n.º 10
0
 def on_color(self, event):
     ColorManager.set_front(self.btns.index(event.GetEventObject()))