Пример #1
0
def draw_artificial_image(shape,
                          pos,
                          radius,
                          noise_level,
                          dip=False,
                          traditional=False,
                          **kwargs):
    radius = tp.utils.validate_tuple(radius, len(shape))

    # tp.locate ignores a margin of size radius, take 1 px more to be safe
    diameter = tuple([(r * 2) + 1 for r in radius])
    size = [d / 2 for d in diameter]

    cols = ['x', 'y', 'z'][:len(shape)][::-1]

    image = draw_features_brightfield(shape, pos, size, noise_level, dip=dip)

    if not traditional:
        result = locate_brightfield_ring(image, diameter, **kwargs)
    else:
        result = locate(image, diameter, **kwargs)

    # For some reason, sorting the DataFrame gives wrong orders in some cases
    result = np.sort(result[cols].astype(float).values, axis=0)
    expected = np.sort(pos, axis=0)

    return result, expected
Пример #2
0
def trackpy_featuring(im, size=10):
    from trackpy.feature import locate
    size = size + (size + 1) % 2
    a = locate(im, size, invert=True)
    pos = np.vstack([a.z, a.y, a.x]).T
    return pos