Esempio n. 1
0
File: test_af.py Progetto: matze/af
def test_load_image_stack():
    # setup two images
    ones = np.ones((256, 256), dtype=np.float)
    zeros = np.zeros((256, 256), dtype=np.float)

    random_name = str(uuid.uuid1())
    img = PIL.Image.fromarray(ones)
    img.save("%s_1.tif" % random_name)
    img = PIL.Image.fromarray(zeros)
    img.save("%s_2.tif" % random_name)

    # now test
    stack = af.load_image_stack('./%s_[0-9]*.tif' % random_name)
    assert stack.shape[2] == 2
    assert np.array_equal(stack[:,:,0], ones)
    assert np.array_equal(stack[:,:,1], zeros)

    # cleanup
    os.remove("%s_1.tif" % random_name)
    os.remove("%s_2.tif" % random_name)
Esempio n. 2
0
File: ui.py Progetto: matze/af
    def __init__(self):
        self.stack = af.load_image_stack("data/*.jpg")

        win = gtk.Window()
        win.connect("destroy", lambda x: gtk.main_quit())
        win.set_default_size(960, 540)
        win.set_title("Autofocus Test")

        vpane = gtk.VPaned()
        win.add(vpane)

        self.canvas = FocusCanvas()
        self.canvas.connect('region-updated', self._on_region_update)
        self.canvas.update_image(self.stack[:,:,0])
        vpane.add(self.canvas)

        self.figure = Figure(figsize=(5, 1), dpi=100)
        self.ax = self.figure.add_subplot(111)
        self.figure_widget = FigureWidget(self.figure)
        vpane.add(self.figure_widget)

        win.show_all()
Esempio n. 3
0
File: test_af.py Progetto: matze/af
def test_load_image_stack_none():
    assert af.load_image_stack("") == None