def on_clear(self, event): ips = IPy.get_ips() if ips is None: return hist = ips.histogram() self.curvepan.set_hist(hist) ips.lut = ColorManager.get_lut() ips.update = 'pix'
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'
def run(self, tps, data, snap, 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_lut(para['cm'])/255.0 cm = None if para['cs'] == 'None' else colors.ListedColormap(cm, N=256) data.plot.scatter(x=para['x'], y=para['y'], s=rs, c=cs, alpha=para['alpha'], cmap=cm, grid=para['grid'], title=para['title']) plt.show()
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_lut(para['cm']) newips.chan_mode = modes[idx.index(para['mode'])] #newips.range = (0, para['n']) IPy.show_ips(newips)
def load(self): plus = IPy.get_ips() if plus==None: img = np.ones((30,1), dtype=np.uint8) * np.arange(256, dtype=np.uint8) ips = ImagePlus([img], self.title) ips.lut = ColorManager.get_lut(self.title) IPy.show_ips(ips) return False elif plus.channels != 1: IPy.alert('RGB image do not surport Lookup table!') return False return True
def on_cmapsel(self, event): key = self.cmapsel.GetValue() lut = ColorManager.get_lut(key) n = self.spn_num.GetValue() + 1 idx = np.linspace(0, 255, n).astype(int) cs = list(lut[idx]) + [(128, 128, 128)] * (16 - n) for btn, c in zip(self.btns, cs): btn.SetBackgroundColour(c) ips = ImageManager.get() if ips is None: return newlut = lut * 0 newlut[:n] = lut[idx] ips.lut = newlut ips.update()
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_lut(para['cm'])
def on_cmapsel(self): ips = IPy.get_ips() if ips is None: return key = self.cmapsel.GetValue() ips.lut = ColorManager.get_lut(key) ips.update = 'pix'
def run(self, para=None): plus = IPy.get_ips() plus.lut = ColorManager.get_lut(self.title) plus.update = 'pix'