Esempio n. 1
0
    def run(self, para=None):
        root_dir = osp.abspath(osp.dirname(self.path))
        print(root_dir)
        path = osp.join(root_dir, self.name)
        if osp.isfile(path):
            fp, fn = osp.split(path)
            fn, fe = osp.splitext(fn)
            read = ReaderManager.get(fe[1:])
            view = ViewerManager.get(fe[1:]) or IPy.show_img

            group, read = (True,
                           read[0]) if isinstance(read, tuple) else (False,
                                                                     read)
            img = read(path)
            if img.dtype == np.uint8 and img.ndim == 3 and img.shape[2] == 4:
                img = img[:, :, :3].copy()
            if not group: img = [img]
        else:
            names = [i for i in os.listdir(path) if '.' in i]
            read = ReaderManager.get(names[0].split('.')[1])
            view = ViewerManager.get(names[0].split('.')[1]) or IPy.show_img
            imgs = []
            for i in range(len(names)):
                self.progress(i, len(names))
                imgs.append(read(osp.join(path, names[i])))
            img = imgs
        view(img, self.title)
Esempio n. 2
0
    def run(self, para=None):
        fp, fn = os.path.split(para['path'])
        fn, fe = os.path.splitext(fn)
        read = ReaderManager.get(fe[1:])
        view = ViewerManager.get(fe[1:]) or show

        try:
            img = read(para['path'])
        except:
            IPy.alert('unknown img format!')
            return

        files = self.getfiles(para['path'])
        files.sort()
        imgs = self.readimgs(files[para['start']:para['end'] + 1:para['step']],
                             read, img.shape, img.dtype)
        view(imgs, para['title'])
Esempio n. 3
0
from imagepy.core.util import fileio
from skimage.io import imread, imsave
from imagepy.core.manager import ReaderManager, WriterManager

ReaderManager.add('jpg', imread)
WriterManager.add('jpg', imsave)
ReaderManager.add('jpeg', imread)
WriterManager.add('jpeg', imsave)
class OpenFile(fileio.Reader):
	title = 'JPG Open'
	filt = ['JPG','JPEG']

class SaveFile(fileio.Writer):
	title = 'JPG Save'
	filt = ['JPG','JPEG']

plgs = [OpenFile, SaveFile]
Esempio n. 4
0
 def load(self):
     self.filt = sorted(ReaderManager.all())
     return True
Esempio n. 5
0
from imagepy.core.util import fileio
from skimage.io import imread, imsave
from imagepy.core.manager import ReaderManager, WriterManager

ReaderManager.add('tif', imread)
WriterManager.add('tif', imsave)


class OpenFile(fileio.Reader):
    title = 'TIF Open'
    filt = [('TIF', ('TIF', 'TIFF', 'tif', 'tiff'))]


class SaveFile(fileio.Writer):
    title = 'TIF Save'
    filt = [('TIF', ('TIF', 'TIFF', 'tif', 'tiff'))]


plgs = [OpenFile, SaveFile]
Esempio n. 6
0
from imagepy.core.util import fileio
import numpy as np
from imagepy.core.manager import ReaderManager, WriterManager
def imread(path):
	return np.loadtxt(path,dtype=float)
def imsave(path,img):
	np.savetxt(path,img)
ReaderManager.add('dat', imread)
WriterManager.add('dat', imsave)
class OpenFile(fileio.Reader):
	title = 'DAT Open'
	filt = ['DAT']

class SaveFile(fileio.Writer):
	title = 'DAT Save'
	filt = ['DAT']

plgs = [OpenFile,SaveFile]
Esempio n. 7
0
    def start(self, para=None, callafter=None):
        wb = pyxl.load_workbook(self.cont)
        xlreport.repair(wb)
        info, key = xlreport.parse(wb)
        if para is not None:
            return self.runasyn(wb, info, para, callafter)
        dialog = GridDialog(IPy.curapp, self.title, info, key)
        rst = dialog.ShowModal()
        para = dialog.GetValue()
        dialog.Destroy()
        if rst != 5100: return
        filt = '|'.join(['%s files (*.%s)|*.%s' % ('XLSX', 'xlsx', 'xlsx')])
        if not IPy.getpath('Save..', filt, 'save', para): return
        win = WidgetsManager.getref('Macros Recorder')
        if win != None: win.write('{}>{}'.format(self.title, para))
        self.runasyn(wb, info, key, para, callafter)


def show_rpt(data, title):
    wx.CallAfter(Report(title, data).start)


ViewerManager.add('rpt', show_rpt)


def read_rpt(path):
    return path


ReaderManager.add('rpt', read_rpt, tag='rpt')
Esempio n. 8
0
 def load(self):
     self.filt = sorted(ReaderManager.get(tag=None))
     return True
Esempio n. 9
0
from imagepy.core.util import tableio
from pandas import read_csv, read_excel, read_hdf
from imagepy import IPy
from imagepy.core.manager import ReaderManager, WriterManager, ViewerManager


def show(data, title):
    IPy.show_table(data, title)


ViewerManager.add('tab', show)

save_csv = lambda path, data: data.to_csv(path)
ReaderManager.add('csv', read_csv, tag='tab')
WriterManager.add('csv', save_csv, tag='tab')


class OpenCSV(tableio.Reader):
    title = 'CSV Open'
    filt = ['csv']


class SaveCSV(tableio.Writer):
    title = 'CSV Save'
    filt = ['csv']


save_excel = lambda path, data: data.to_excel(path)
ReaderManager.add(['xls', 'xlsx'], read_excel, tag='tab')
WriterManager.add(['xls', 'xlsx'], save_excel, tag='tab')
Esempio n. 10
0
from imagepy.core.util import fileio
import numpy as np
from imagepy.core.manager import ReaderManager, WriterManager
from imagepy import IPy
import os

ReaderManager.add('npy', np.load)
WriterManager.add('npy', np.save)


class OpenFile(fileio.Reader):
    title = 'Numpy Open'
    filt = ['npy']


class SaveFile(fileio.Writer):
    title = 'Numpy Save'
    filt = ['npy']


class Open3D(fileio.Reader):
    title = 'Numpy 3D Open'
    filt = ['npy']

    def run(self, para=None):
        imgs = np.load(para['path'])
        fp, fn = os.path.split(para['path'])
        fn, fe = os.path.splitext(fn)
        IPy.show_img(imgs, fn)

Esempio n. 11
0
from imagepy.core.util import fileio
from skimage.io import imread, imsave
from imagepy.core.manager import ReaderManager, WriterManager

ReaderManager.add('bmp', imread)
WriterManager.add('bmp', imsave)


class OpenFile(fileio.Reader):
    title = 'BMP Open'
    filt = ['BMP']


class SaveFile(fileio.Writer):
    title = 'BMP Save'
    filt = ['BMP']


plgs = [OpenFile, SaveFile]
Esempio n. 12
0
    def run(self):
        self.next()

    #IPy.run_macros(self.cmds)

    def __call__(self):
        return self

    def start(self, para=None, callafter=None):
        self.callafter = callafter
        self.cur = 0
        self.run()


def show_mc(data, title):
    wx.CallAfter(Macros(title, data).start)


ViewerManager.add('mc', show_mc)


def read_mc(path):
    f = open(path, encoding='utf-8')
    cont = f.readlines()
    f.close()
    print(cont)
    return cont


ReaderManager.add('mc', read_mc, tag='mc')
Esempio n. 13
0
from imagepy.core.util import fileio
from scipy.io import savemat, loadmat
from imagepy.core.manager import ReaderManager, WriterManager
from imagepy import IPy
import os

ReaderManager.add('mat', lambda path: loadmat(path)['img'])
WriterManager.add('mat', lambda path, img: savemat(path, {'img': img}))


class OpenFile(fileio.Reader):
    title = 'Mat Open'
    filt = ['Mat']


class SaveFile(fileio.Writer):
    title = 'Mat Save'
    filt = ['mat']


class Open3D(fileio.Reader):
    title = 'Mat 3D Open'
    filt = ['Mat']

    def run(self, para=None):
        imgs = loadmat(para['path'])['img']
        fp, fn = os.path.split(para['path'])
        fn, fe = os.path.splitext(fn)
        IPy.show_img(imgs, fn)

Esempio n. 14
0
		self.cont = cont

	def __call__(self):
		return self

	def start(self, para=None, callafter=None):
		pan = WorkFlowPanel(IPy.curapp)
		pan.load(self.cont, self.workflow)
		info = aui.AuiPaneInfo(). DestroyOnClose(True). Left(). Caption(self.title)  .PinButton( True ) \
			.Resizable().FloatingSize( wx.DefaultSize ).Dockable(IPy.uimode()=='ipy').Layer( 5 ) 
		
		if IPy.uimode()=='ipy': info.Dock().Top()
		if IPy.uimode()=='ij': info.Float()
		IPy.curapp.auimgr.AddPane(pan, info)
		IPy.curapp.Layout()
		IPy.curapp.auimgr.Update()

def show_wf(data, title):
	wx.CallAfter(WorkFlow(title, data).start)

ViewerManager.add('wf', show_wf)

def read_wf(path):
	f = open(path, encoding='utf-8')
	cont = f.read()
	f.close()
	print(cont)
	return cont

ReaderManager.add('wf', read_wf, tag='wf')
Esempio n. 15
0
from imagepy.core.util import fileio
import pydicom
from imagepy.core.manager import ReaderManager, WriterManager


def imread(path):
    return pydicom.read_file(path, force=True).pixel_array


ReaderManager.add('dcm', imread)


class OpenFile(fileio.Reader):
    title = 'DCM Open'
    filt = ['DCM']


plgs = [OpenFile]
Esempio n. 16
0
from imagepy.core.util import fileio
from imagepy.core.engine import Free, Simple
from imagepy import IPy
from scipy.misc import imread, imsave
from imagepy.core.manager import ReaderManager, WriterManager
import cv2, wx, os
import numpy as np

ReaderManager.add('tif', lambda p:cv2.imread(p, False))
WriterManager.add('tif', cv2.imwrite)

class OpenFile(fileio.Reader):
	title = 'TIF Open'
	filt = ['TIF']

class SaveFile(fileio.Writer):
	title = 'TIF Save'
	filt = ['TIF']

class Writer(Simple):
	title = 'Video Writer'
	note = ['rgb', '8-bit']
	para = {'path':'','fps':24, 'down':1}
	#para = {'path':'./','name':'','format':'png'}

	view = [(int, 'fps', (1,120), 0, 'frame', '/s'),
			(int, 'down', (1,10), 0, 'down sample', 'down', '')]

	def show(self):
		self.para['name'] = self.ips.title
		rst = IPy.get_para('Save Video', self.view, self.para)
Esempio n. 17
0
from imagepy.core.util import fileio
from scipy.misc import imread, imsave
from imagepy.core.manager import ReaderManager, WriterManager

ReaderManager.add('png', imread)
WriterManager.add('png', imsave)


class OpenFile(fileio.Reader):
    title = 'PNG Open'
    filt = ['PNG']


class SaveFile(fileio.Writer):
    title = 'PNG Save'
    filt = ['PNG']


plgs = [OpenFile, SaveFile]
Esempio n. 18
0
import wx, joblib, os, shutil, os.path as osp
from glob import glob
from imagepy.core.manager import RoiManager, ImageManager, ReaderManager, ViewerManager
from imagepy.core.engine import Macros
from . import classify_plgs as manager
from .predict_plg import Plugin as FCL
from imagepy import IPy

ReaderManager.add('fcl', lambda x: x, 'fcl')
ViewerManager.add('fcl', lambda x, n: wx.CallAfter(FCL(path=x).start))


class Plugin(wx.Panel):
    title = 'Feature Classify Panel'

    def __init__(self, parent):
        wx.Panel.__init__(self,
                          parent,
                          id=wx.ID_ANY,
                          pos=wx.DefaultPosition,
                          size=wx.Size(256, 256),
                          style=wx.TAB_TRAVERSAL)

        sizer = wx.BoxSizer(wx.HORIZONTAL)

        sizer_btns = wx.BoxSizer(wx.VERTICAL)

        self.btn_save = wx.Button(self, wx.ID_ANY, u"Save", wx.DefaultPosition,
                                  wx.DefaultSize, 0)
        sizer_btns.Add(self.btn_save, 0, wx.ALL, 5)