Пример #1
0
# samples, comp_cfg = dt.open_sampled('2017-08-04_14:46:29.npy', mode='simulation')

# pc = PlatformCoordinates()

task = 'acquire'
if task is 'acquire':
    image_dict = dict()
    save_yaml_metadata(out_file, cfg)
    for index, theta, shift, acqpars in iterator:
        image_dict[(theta, phi)] = client.acquire(theta, phi, power)
    np.save(out_file, image_dict)


elif task is 'reconstruct':
    start_time = time.time()
    rec, phase = fpm_reconstruct(samples=samples, backgrounds=None, it=iterator,
                                init_point=[0, 0], cfg=comp_cfg, debug=True)
    print('--- %s seconds ---' % (time.time() - start_time))
    plt.imshow(rec), plt.gray()
    plt.show()

if task is 'test_and_measure':
    image_dict = np.load(out_file)
    for index, theta, phi, power in iterator:
        if phi == 20 or phi == 40:
            im_array = image_dict[()][(theta, phi)]
            intensity = np.mean(im_array)
            print('int: %f, theta: %d, phi: %d' % (intensity, theta, phi))
            ax = plt.gca() or plt
            ax.imshow(im_array, cmap=plt.get_cmap('gray'))
            ax.get_figure().canvas.draw()
            plt.show(block=False)
Пример #2
0
from pyfpm import web
from pyfpm.reconstruct import fpm_reconstruct
from pyfpm.fpmmath import set_iterator
from pyfpm.data import save_yaml_metadata
import pyfpm.data as dt
from pyfpm.coordinates import PlatformCoordinates

# Simulation parameters
cfg = dt.load_config()
samples, comp_cfg = dt.open_sampled('2017-05-26_152307.npy')
background, comp_cfg = dt.open_sampled('2017-05-26_145449_blank.npy')

# Connect to a web client running serve_microscope.py
pc = PlatformCoordinates(theta=0, phi=0, height=cfg.sample_height, cfg=cfg)
pc.generate_model(cfg.plat_model)
iterator = set_iterator(cfg)

# reconstruction
dx = cfg.patch_size[0]
x_range = range(0, cfg.video_size[1], dx)[:-1]
y_range = range(0, cfg.video_size[0], dx)[:-1]
# for i, point in enumerate(it.product(x_range, y_range)):
#     init_point = [point[0], point[1]]
#     rec, phase = fpm_reconstruct(samples, background, iterator, init_point,
#                           cfg=cfg, debug=False)
#     misc.imsave('./misc/ph'+str(i)+'.png', phase)
#     misc.imsave('./misc/im'+str(i)+'.png', rec)
rec, phase = fpm_reconstruct(samples, background, iterator, [90, 80],
                            cfg=comp_cfg, debug=True)
plt.show()
Пример #3
0
        img = client.acquire(theta_plat, phi_plat, shift, power)
        im_array = misc.imread(StringIO(img.read()), 'RGB')
        image_dict[(theta, phi)] = im_array
        ax = plt.gca() or plt
        ax.imshow(im_array)
        ax.get_figure().canvas.draw()
        plt.show(block=False)
    print(out_file)
    np.save(out_file, image_dict)
    client.acquire(0, cfg.servo_init, 0)

elif task is 'reconstruct':
    print("here", cfg.video_size)

    start_time = time.time()
    rec = fpm_reconstruct(in_file, iterator, cfg=cfg, debug=True)
    print('--- %s seconds ---' % (time.time() - start_time))
    plt.imshow(rec), plt.gray()
    plt.show()

if task is 'complete_scan':
    print(task)
    json_savemeta(json_file, image_size, pupil_radius, theta_max, phi_max)
    client.complete_scan(color)

if task is 'test_and_measure':
    fig, ax = plt.subplots(1, 1, figsize=(25, 15))
    im1 = ax.imshow(np.ones((480, 640)), cmap=plt.get_cmap('hot'))
    fig.show()
    while 1:
        img = client.get_camera_picture()