コード例 #1
0
    def __init__(self, lfp_path=None):
        self._tkroot = Tkinter.Tk()
        self._lfp_path = lfp_path
        if lfp_path is None:
            self._lfp_path = tkFileDialog.askopenfilename(defaultextension="lfp")
        self._tkroot.wm_title(os.path.basename(self._lfp_path))
        self._tkroot.protocol("WM_DELETE_WINDOW", self.quit)
        self._tkroot.geometry("%dx%d" % self._active_size)
        #self._tkroot.bind('<Configure>', self.resize)

        self._lfp = LfpPictureFile(self._lfp_path).load()
        try:
            self._depth_lut = self._lfp.refocus_stack.depth_lut
            self._images = dict( (i.chunk.sha1, Image.open(StringIO(i.chunk.data)))
                for i in self._lfp.refocus_stack.images)
        except:
            raise Exception("Not a Processed LFP Picture file")

        self._pic = Tkinter.Label(self._tkroot)
        self._pic.bind("<Button-1>", self.click)
        self._pic.pack()

        self.focus_image()

        self._tkroot.mainloop()
コード例 #2
0
def export(lfp_files, **null):
    """Export LFP Picture file into separate data files
    """
    for idx, lfp_file in enumerate(lfp_files):
        if not QUIET:
            if idx > 0: print()
            print("LFP Picture file: %s" % lfp_file.name)
        LfpPictureFile(lfp_file).load().export()
コード例 #3
0
def info(lfp_files, **null):
    """Show information about LFP Picture file
    """
    for idx, lfp_file in enumerate(lfp_files):
        if not QUIET:
            if idx > 0: print()
            print("LFP Picture file: %s" % lfp_file.name)
        LfpPictureFile(lfp_file).load().print_info()
コード例 #4
0
class LfpPictureViewer():
    """View and refocues Processed LFP Picture files (*-stk.lfp)
    """

    _active_size = (648, 648)
    _tkroot = None
    _lfp_path = None
    _lfp = None
    _active_sha1 = None
    _images = None
    _depth_lut = None

    def __init__(self, lfp_path=None):
        self._tkroot = Tkinter.Tk()
        self._lfp_path = lfp_path
        if lfp_path is None:
            self._lfp_path = tkFileDialog.askopenfilename(defaultextension="lfp")
        self._tkroot.wm_title(os.path.basename(self._lfp_path))
        self._tkroot.protocol("WM_DELETE_WINDOW", self.quit)
        self._tkroot.geometry("%dx%d" % self._active_size)
        #self._tkroot.bind('<Configure>', self.resize)

        self._lfp = LfpPictureFile(self._lfp_path).load()
        try:
            self._depth_lut = self._lfp.refocus_stack.depth_lut
            self._images = dict( (i.chunk.sha1, Image.open(StringIO(i.chunk.data)))
                for i in self._lfp.refocus_stack.images)
        except:
            raise Exception("Not a Processed LFP Picture file")

        self._pic = Tkinter.Label(self._tkroot)
        self._pic.bind("<Button-1>", self.click)
        self._pic.pack()

        self.focus_image()

        self._tkroot.mainloop()

    def focus_image(self, x=.5, y=.5):
        self._active_sha1 = self._lfp.find_most_focused_f(x, y).chunk.sha1
        self.draw_image(self._active_size)

    def draw_image(self, size):
        self._active_image = self._images[self._active_sha1].resize(size, Image.ANTIALIAS)
        self._pimage = ImageTk.PhotoImage(self._active_image)
        self._pic.configure(image=self._pimage)

    def click(self, event):
        self.focus_image(event.x / self._active_size[0],
                         event.y / self._active_size[1])

    def quit(self):
        self._tkroot.destroy()
        self._tkroot.quit()
コード例 #5
0
OUTPUT_FORMATS = ('jpeg', 'png')


def usage(errcode=0, of=sys.stderr):
    print ("Usage: %s picture-file.lfp" %
            os.path.basename(sys.argv[0]))
    sys.exit(errcode)

if __name__=='__main__':
    if len(sys.argv) < 2 or len(sys.argv) > 2:
        usage()
    lfp_path = sys.argv[1]


    try:
        lfp = LfpPictureFile(lfp_path).load()

        try:
            depth_lut = lfp.refocus_stack.depth_lut
            images = lfp.refocus_stack.images
            width  = lfp.refocus_stack.default_width
            height = lfp.refocus_stack.default_height
        except:
            raise Exception("Not a Processed LFP Picture file")

        p_app_focused = PImage.open(StringIO(images[0].chunk.data))
        p_images = dict((image.chunk.sha1, PImage.open(StringIO(image.chunk.data)))
            for image in images)

        for i in xrange(depth_lut.width):
            for j in xrange(depth_lut.height):
コード例 #6
0

"""Export LFP Picture file into separate data files
"""


import os.path
import sys

from lfp_reader import LfpPictureFile


def usage(errcode=0, of=sys.stderr):
    print ("Usage: %s picture-file.lfp" %
            os.path.basename(sys.argv[0]))
    sys.exit(errcode)

if __name__=='__main__':
    if len(sys.argv) < 2 or len(sys.argv) > 2:
        usage()
    lfp_path = sys.argv[1]

    try:
        lfp = LfpPictureFile(lfp_path).load()
        lfp.export()

    except Exception as err:
        print >>sys.stderr, "Error:", err
        exit(1)