Esempio n. 1
0
def find_kilobots(image_filename, output_filename):
    """Find kilobots in a still image file."""

    kilobot_image = Image.from_file(image_filename)
    red_only = kilobot_image[:,:,0]

    imsave('red.png', red_only)
    edges = find_edges(red_only)
    blurred = gaussian_filter(edges, sigma=2)

    # bot_template = blurred[135:185,485:535]

    # imsave('bot_template.png', bot_template)

    bot_template = load_bot_template('bot_template.png')

    match_result = skimage.feature.match_template(blurred, bot_template, pad_input=True)

    imsave('match_result.png', match_result)

    selected_area = match_result > 0.6

    imsave('selected_area.png', selected_area)

    ccs = find_connected_components(selected_area)
    centroids = component_centroids(ccs)

    return centroids
Esempio n. 2
0
def find_template_leader(filename):
    """Find template kilobot for matching. Currently hard-c"""

    kilobot_image = Image.from_file(filename)
    red_only = kilobot_image[:,:,0]

    edges = find_edges(red_only)
    blurred = gaussian_filter(edges, sigma=5)

    x1 = 255
    x2 = 325
    y1 = 650
    y2 = 710

    bot_template = blurred[x1:x2,y1:y2]

    return bot_template
Esempio n. 3
0
def find_template(filename):
    """Find template kilobot for matching. Currently hard-c"""

    kilobot_image = Image.from_file(filename)
    red_only = kilobot_image[:,:,0]

    edges = find_edges(red_only)
    blurred = gaussian_filter(edges, sigma=2)

    x1 = 135
    x2 = 185
    y1 = 485
    y2 = 535

    bot_template = blurred[135:185,485:535]

    return bot_template