Пример #1
0
"""
from StringIO import StringIO
import time

import matplotlib.pyplot as plt
import h5py
from scipy import misc
import numpy as np
import json

from pyfpm import web
from pyfpm.fpmmath import iter_positions, recontruct
from pyfpm.data import save_metadata

# Connect to a web client running serve_microscope.py
client = web.Client('http://10.99.38.48:5000/acquire')

color = "green"
out_hf = 'P1.h5'
# Obs: pup_rad = nx*NA/n where n is the refraction index of the medium
ns = 0.3  # Complement of the overlap between sampling pupils
pupil_radius = 80
phi_max = 90
image_size = (480, 640)

iterator_list = list(iter_positions(phi_max=phi_max, mode="leds"))
task = "inspect"
if task is "acquire":
    with h5py.File(out_hf, 'w') as hf:
        print("I will take %s images" % len(iterator_list))
        save_metadata(hf, image_size, iterator_list, pupil_radius, ns, phi_max)
Пример #2
0
###############################################################################
# File simulate_and_sample.py
# With an already hosted server aqcuires the microscope image from the remote
# client and simulates the same image from the local computer.
#
###############################################################################
from pyfpm import web

client = web.Client(url)

for theta, phi, power in iter_positions(40, .5):
    img = client.acquire(theta, phi, power)

# procesas
Пример #3
0
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
import matplotlib.cm as cm
from scipy import misc
# import h5py

import pyfpm.fpmmath as fpm
from pyfpm import web
import pyfpm.coordtrans as ct
import pyfpm.data as dt

# Simulation parameters
cfg = dt.load_config()
out_file = dt.generate_out_file(cfg.output_sample)
# Connect to a web client running serve_microscope.py
client = web.Client(cfg.server_ip)

# xoff=1250, yoff=950
def acquire_image_pattern(ss, pattern, Nmean=1):
    image_mean = np.zeros(cfg.patch_size)
    for i in range(Nmean):
        image_response = client.acquire_ledmatrix_pattern(pattern=pattern, power=255, color='R', shutter_speed=ss, iso=400, xoff=0, yoff=0)
        image_i = np.array(image_response).reshape(cfg.patch_size)
        image_mean += image_i
    return image_mean/(Nmean)

def mencoded(angle):
    matrix = fpm.create_source_pattern(shape='semicircle', angle=angle, int_radius=2, radius=5,)
    pattern = fpm.hex_encode(matrix)
    return pattern
Пример #4
0
# Obs: pup_rad = nx*NA/n where n is the refraction index of the medium
# ns = 0.3  # Complement of the overlap between sampling pupils
# Simulation parameters
image_size = cfg.video_size
wavelength = cfg.wavelength
pixelsize = cfg.pixel_size  # See jupyter notebook
phi_min, phi_max, phi_step = cfg.phi
theta_min, theta_max, theta_step = cfg.theta
pupil_radius = cfg.pupil_size / 2

mode = cfg.task
itertype = cfg.sweep
server_ip = cfg.server_ip

# Connect to a web client running serve_microscope.py
client = web.Client(server_ip)
pc = PlatformCoordinates(theta=0, phi=0, height=cfg.sample_height, cfg=cfg)
pc.generate_model(cfg.plat_model)
# Obs: pup_rad = nx*NA/n where n is the refraction index of the medium
# Opens input image as if it was sampled at pupil_pos = (0,0) with high
# resolution details
iterator = set_iterator(cfg)

task = 'reconstruct'
if task is 'acquire':
    image_dict = dict()
    save_yaml_metadata(out_file, cfg)
    for index, theta, phi, power in iterator:
        pc.set_coordinates(theta, phi, units='degrees')
        [theta_plat, phi_plat, shift, power] = pc.parameters_to_platform()
        print("parameters to platform", theta_plat, phi_plat, shift, power)