示例#1
0
from StringIO import StringIO

# Simulation parameters
out_file = './outputs/pinhole_simulated.png'
out_hf = 'pinhole_3.h5'
## Obs: pup_rad = nx*NA/n where n is the refraction index of the medium
pupil_radius = 20
ns = 0.3  # Comlement of the overlap between sampling pupils
phi_max = 20

# Opens input image as if it was sampled at pupil_pos = (0,0) with high
# resolution details
with open('pinhole_square.png', "r") as imageFile:
    image = imageFile.read()
    image_size = np.shape(misc.imread(StringIO(image), 'RGB'))
client = local.SimClient(image, image_size, pupil_radius, ns)
iterator_list = list(
    iter_positions(pupil_radius, ns, phi_max, image_size, "leds"))

# Acquiring simulated images
task = "reconstruct"
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)
        for index, theta, phi, power in iterator_list:
            print(index, theta, phi, power)
            img = client.acquire(theta, phi, power)
            hf.create_dataset(str(index), data=img)

elif task is "reconstruct":
示例#2
0
import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
import numpy as np

from pyfpm.fpmmath import *
import pyfpm.data as dt
from pyfpm.data import save_yaml_metadata
import pyfpm.local as local
from pyfpm.coordinates import PlatformCoordinates


# Simulation parameters
CONFIG_FILE = '/home/lec/pyfpm/config.yaml'
cfg = dt.load_config(CONFIG_FILE)
client = local.SimClient(cfg=cfg)
iterator = set_iterator(cfg)
#
pc = PlatformCoordinates(theta=0, phi=0, height=cfg.sample_height, cfg=cfg)


image_dict = dict()
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(25, 15))
fig.show()

for index, theta, phi in iterator:
    # pupil = generate_pupil(theta, phi, power, cfg.video_size,
    #                        cfg.wavelength, cfg.pixel_size, cfg.objective_na)
    pc.set_coordinates(theta=theta, phi=phi, units='degrees')
    t_corr, p_corr = pc.source_coordinates(mode='angular')
    power = 100
示例#3
0
###############################################################################
# File serve_simulated.py
# Hosts and serves simulated images.
# Perhaps this is just for completion. I can't see any short-term use of this
# function.
#
###############################################################################
from pyfpm.web import create_server
import pyfpm.local as local
from pyfpm.devices import LaserAim, Camera
from pyfpm.fpmmath import iter_positions

size = (480, 640)
pup_rad = 40
overlap = 0.5
rmax = 320

with open('pinhole.png', "rb") as imageFile:
    image = imageFile.read()
client = local.SimClient(image, size, pup_rad)

app.run(host='0.0.0.0')