Esempio n. 1
0
def test_subimage():
    i = detector_grid(shape=(10, 10), spacing=1)
    s = subimage(i, (5, 5), 2)
    assert s.shape == (1, 2, 2)

    i2 = data_grid(i, 1)
    s2 = subimage(i2, (5, 5), 2)
Esempio n. 2
0
def test_subimaged():
    # make a dummy image so that we can pretend we are working with
    # data we want to subimage
    im = xschema
    h = calc_holo(im, sphere, index, wavelen, xpolarization)
    sub = (60, 70), 30
    hs = calc_holo(subimage(im, *sub), sphere, index, wavelen, xpolarization)

    assert_obj_close(subimage(h, *sub), hs)
Esempio n. 3
0
def load_bgdivide_crop_v2(
        path, metadata, particle_position, bkg, dark, channel=RGB_CHANNEL,
        size=HOLOGRAM_SIZE):
    data = hp.load_image(path, channel=channel, **metadata)
    data = bg_correct(data, bkg, dark)
    data = subimage(data, particle_position[::-1], size)
    data = normalize(data)
    return data
Esempio n. 4
0
def load_bgdivide_crop(
        path, metadata, particle_position, bg_prefix="bg", df_prefix=None,
        channel=RGB_CHANNEL, size=HOLOGRAM_SIZE):
    data = hp.load_image(path, channel=channel, **metadata)
    bkg = load_bkg(path, bg_prefix, refimg=data)
    dark = None  # load_dark(path, df_prefix, refimg=data)
    data = bg_correct(data, bkg, dark)
    data = subimage(data, particle_position[::-1], size)
    data = normalize(data)
    return data
Esempio n. 5
0
def load_bgdivide_crop(path,
                       metadata,
                       particle_position,
                       bkg,
                       dark,
                       channel=RGB_CHANNEL,
                       size=HOLOGRAM_SIZE,
                       recenter=True):
    data = hp.load_image(path, channel=channel, **metadata)
    data = bg_correct(data, bkg, dark)

    if recenter:
        bbox = subimage(data, particle_position, size)
        bbox_corner = np.array([bbox.x.min(), bbox.y.min()])
        found_position = np.round(
            center_find(bbox) + bbox_corner / metadata['spacing'])
        data = subimage(data, found_position, size)
    else:
        data = subimage(data, particle_position, size)
    data = normalize(data)
    if recenter:
        return data, found_position
    return data, None
Esempio n. 6
0
def test_ps():

    imagepath = get_example_data_path('ps_image01.jpg')
    bgpath = get_example_data_path('ps_bg01.jpg')
    L = 0.0407 # distance from light source to screen
    cam_spacing = 12e-6 # linear size of camera pixels
    mag = 9.0 # magnification
    npix_out = 1020 # linear size of output image (pixels)
    zstack = [1.08e-3, 1.18e-3] # distances from camera to reconstruct

    holo = load_image(imagepath, spacing=cam_spacing, illum_wavelen=406e-9, medium_index=1) # load hologram
    bg = load_image(bgpath, spacing=cam_spacing) # load background image
    holo = bg_correct(holo, bg+1, bg) # subtract background
    holo = subimage(holo,[250,500],300)
    beam_c = center_of_mass(bg.values.squeeze()) # get beam center
    simplefilter('ignore')
    recons = ps_propagate(holo, zstack, L, beam_c) # do propagation

    verify(recons, 'ps_recon')
Esempio n. 7
0
def test_subimage_floats():
    i = data_grid(np.zeros((100, 100)), .1)
    s1 = subimage(i, (5.2, 5.6), 2)
    s2 = subimage(i, (5, 6), 2)
    assert_obj_close(s1, s2)
Esempio n. 8
0
 def _load_data(self, name):  # need metadata, particle_position!
     data = hp.load_image(name, channel=RGB_CHANNEL, **self.metadata)
     data = bg_correct(data, self._background, self._darkfield)
     data = subimage(data, self.particle_position[::-1], HOLOGRAM_SIZE)
     data = normalize(data)
     return data