Exemplo n.º 1
0
 def run(self, tps, snap, data, para=None):
     table = TableManager.get(para['temp']).get_subtab()
     box = gutil.shp2box(table, para['scale']
                         or (para['width'], para['height']), para['mar'])
     chans = list(data['channels'][0])
     chans = [chans.index(i) for i in para['chans']]
     order = {'nearest': 0, 'linear': 1}[para['order']]
     rst = gmt.match_idx(data, box, chans, step=para['step'], order=order)
     IPy.show_img([rst], tps.title + '-merge')
Exemplo n.º 2
0
 def run(self, ips, imgs, para=None):
     table = TableManager.get(para['temp']).get_subtab()
     box = gutil.shp2box(table, para['scale']
                         or (para['width'], para['height']), para['mar'])
     chans = ['Channel %s' % i for i in range(ips.get_nchannels())]
     chans = [chans.index(i) for i in para['chans']]
     order = {'nearest': 0, 'linear': 1}[para['order']]
     rst = gmt.match_multi(imgs, box, chans, step=para['step'], order=order)
     IPy.show_img([rst], ips.title + '-merge')
Exemplo n.º 3
0
	def run(self, ips, imgs, para=None):
		idx = TableManager.get(para['index']).data
		idx = idx.to_crs(ips.data['prjs'][0])
		s = 0
		for img, prj, m in zip(imgs, ips.data['prjs'], ips.data['trans']):
			img[:] = 0; s+= 1
			self.progress(s, len(imgs))
			for i in idx.index:
				box = raster_box(img.shape, prj, m)
				if box.intersects(idx.loc[i]['geometry']):
					raster = read_tif(idx.loc[i]['path'])[0]
					raster2des(raster, (img, prj, m), 10)
Exemplo n.º 4
0
    def run(self, ips, imgs, para=None):
        ndvi = ImageManager.get(para['ndvi'])
        lst = ImageManager.get(para['lst'])
        lab = ImageManager.get(para['lab'])
        area = ImageManager.get(para['area'])

        ndvi = list(zip(ndvi.imgs, ndvi.data['prjs'], ndvi.data['trans']))[0]
        lst = list(zip(lst.imgs, lst.data['prjs'], lst.data['trans']))[0]
        lab = list(zip(lab.imgs, lab.data['prjs'], lab.data['trans']))[0]
        area = list(zip(area.imgs, area.data['prjs'], area.data['trans']))[0]
        df = TableManager.get(para['df']).data
        rst = wheat.get_grade(ndvi, lst, lab, area, df)
        ips = ImagePlus([rst[0]], 'tiao xiu bing')
        ips.data['prjs'], ips.data['trans'] = [rst[1]], [rst[2]]
        IPy.show_ips(ips)
Exemplo n.º 5
0
    def runasyn(self, wb, info, key, para=None, callback=None):
        TaskManager.add(self)
        for i in para:
            if i in key and key[i][0] == 'img':
                ips = ImageManager.get(para[i])
                para[i] = ips if ips is None else ips.img

            if i in key and key[i][0] == 'tab':
                tps = TableManager.get(para[i])
                para[i] = tps if tps is None else tps.data

        start = time()
        xlreport.fill_value(wb, info, para)
        wb.save(para['path'])
        IPy.set_info('%s: cost %.3fs' % (self.title, time() - start))
        TaskManager.remove(self)
        if callback != None: callback()
Exemplo n.º 6
0
	def run(self, ips, imgs, para = None):
		mats = TableManager.get(para['mat']).data.values
		if len(imgs) != len(mats):
			IPy.alert('image stack must has the same length as transfrom mats!')
			return
		newimgs = []
		img = np.zeros_like(ips.img, dtype=np.float64)
		for i in range(len(mats)):
			tform = tf.ProjectiveTransform(matrix=mats[i].reshape((3,3)))
			if imgs[i].ndim==2: 
				img[:] = tf.warp(imgs[i], tform)
			else:
				for c in range(img.shape[2]):
					img[:,:,c] = tf.warp(imgs[i][:,:,c], tform)
			img -= imgs[i].min(); img *= imgs[i].max() - imgs[i].min()
			if para['new']: newimgs.append(img.astype(ips.img.dtype))
			else: imgs[i] = img
			self.progress(i, len(mats))
		if para['new']: IPy.show_img(newimgs, '%s-trans'%ips.title)
Exemplo n.º 7
0
 def run(self, para=None):
     if para['name'] == 'All':
         for i in TableManager.get_titles():
             WTableManager.get(i).close()
     else:
         WTableManager.get(para['name']).close()
Exemplo n.º 8
0
 def load(self):
     self.para = {'name': 'All'}
     titles = ['All'] + TableManager.get_titles()
     self.view = [(list, 'name', titles, str, 'Name', 'selected')]
     return True
Exemplo n.º 9
0
    def __init__(self, parent, title, tree, key):
        wx.Dialog.__init__(self,
                           parent,
                           -1,
                           title,
                           style=wx.DEFAULT_DIALOG_STYLE,
                           size=wx.Size((300, 480)))
        # wx.Panel.__init__(self, parent, wx.ID_ANY)

        self.panel = panel = wx.Panel(self, wx.ID_ANY)
        topsizer = wx.BoxSizer(wx.VERTICAL)

        # Difference between using PropertyGridManager vs PropertyGrid is that
        # the manager supports multiple pages and a description box.
        self.pg = pg = wxpg.PropertyGridManager(
            panel, style=wxpg.PG_SPLITTER_AUTO_CENTER)

        # Show help as tooltips
        pg.SetExtraStyle(wxpg.PG_EX_HELP_AS_TOOLTIPS)

        pg.Bind(wxpg.EVT_PG_CHANGED, self.OnPropGridChange)
        pg.Bind(wxpg.EVT_PG_SELECTED, self.OnPropGridSelect)

        pg.AddPage('Page 1')
        self.key = key
        for page in tree:
            pg.Append(wxpg.PropertyCategory(page[0]))
            for item in page[1]:
                v = item[1]
                if v[0] == 'int':
                    pg.Append(wxpg.IntProperty(v[1], value=int(v[2]) or 0))
                if v[0] == 'float':
                    pg.Append(wxpg.FloatProperty(v[1], value=float(v[2]) or 0))
                if v[0] == 'str':
                    pg.Append(wxpg.StringProperty(v[1], value=v[2] or ''))
                if v[0] == 'txt':
                    pg.Append(wxpg.LongStringProperty(v[1], value=v[2] or ''))
                if v[0] == 'bool': pg.Append(wxpg.BoolProperty(v[1]))
                if v[0] == 'date':
                    pg.Append(wxpg.DateProperty(v[1], value=wx.DateTime.Now()))
                if v[0] == 'list':
                    pg.Append(
                        wxpg.EnumProperty(
                            v[1], v[1],
                            [i.strip() for i in v[2][1:-1].split(',')]))
                if v[0] == 'img':
                    pg.Append(
                        wxpg.EnumProperty(v[1], v[1],
                                          ImageManager.get_titles()))
                if v[0] == 'tab':
                    pg.Append(
                        wxpg.EnumProperty(v[1], v[1],
                                          TableManager.get_titles()))

        topsizer.Add(pg, 1, wx.EXPAND)
        self.txt_info = wx.TextCtrl(self, wx.ID_ANY, 'information',
                                    wx.DefaultPosition, wx.Size(80, 80),
                                    wx.TE_MULTILINE | wx.TRANSPARENT_WINDOW)
        topsizer.Add(self.txt_info, 0, wx.EXPAND | wx.ALL, 0)
        rowsizer = wx.BoxSizer(wx.HORIZONTAL)
        but = wx.Button(panel, wx.ID_OK, "OK")
        rowsizer.Add(but, 1)
        #but.Bind( wx.EVT_BUTTON, self.OnGetPropertyValues )
        but = wx.Button(panel, wx.ID_CANCEL, "Cancel")
        rowsizer.Add(but, 1)
        topsizer.Add(rowsizer, 0, wx.EXPAND)

        panel.SetSizer(topsizer)
        topsizer.SetSizeHints(panel)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(panel, 1, wx.EXPAND)
        self.SetSizer(sizer)
        self.SetAutoLayout(True)