コード例 #1
0
def draw_average_heat_map_rel(image, coordinates_array, click_settings, time_stamps_array, upper, lower):
    """
    a function to draw a heatmap based on the
    :param upper:
    :param lower:
    :param image:
    :param coordinates_array:
    :param click_settings:
    :param time_stamps_array:
    :return:
    """

    click_settings.add_grad_radius_to_shape()

    max_width = image.shape[1]
    max_height = image.shape[0]

    heat_values_array = []

    for idx in range(len(coordinates_array)):

        heat_values = []
        for i in range(max_width * max_height):
            heat_values.append(0.0)

        coordinates = coordinates_array[idx]
        time_stamps = utils.get_element_or_none(time_stamps_array, idx)
        min_idx = 0
        max_idx = len(coordinates)

        if click_settings.use_rectangle:
            for i in range(min_idx, max_idx):
                time = get_time(i, time_stamps)
                fill_for_rectangle(heat_values, coordinates[i][0], coordinates[i][1], click_settings, max_width,
                                   max_height,
                                   time)
        elif click_settings.use_circle:
            for i in range(min_idx, max_idx):
                time = get_time(i, time_stamps)
                fill_for_circle(heat_values, coordinates[i][0], coordinates[i][1], click_settings, max_width,
                                max_height,
                                time)
        elif click_settings.use_ellipse:
            for i in range(min_idx, max_idx):
                time = get_time(i, time_stamps)
                fill_for_ellipse(heat_values, coordinates[i][0], coordinates[i][1], click_settings, max_width,
                                 max_height,
                                 time)

        heat_values_array.append(heat_values)

    final_heat = []
    for i in range(max_width * max_height):
        final_heat.append(0.0)

    for heat_values in heat_values_array:
        for i in range(max_width * max_height):
            final_heat[i] += heat_values[i]


    normalize_heat(final_heat)
    final_heat = [(lower <= heat <= upper) * heat for heat in final_heat]

    draw_heat(image, final_heat)

    click_settings.reset_grad_radius_to_shape()

    return final_heat
コード例 #2
0
def draw_average_heat_map_abs(image, coordinates_array, click_settings, time_stamps_array, upper, lower):
    """
    a function to draw a heatmap based on the
    :param upper:
    :param lower:
    :param image:
    :param coordinates_array:
    :param click_settings:
    :param time_stamps_array:
    :return:
    """

    click_settings.add_grad_radius_to_shape()

    max_width = image.shape[1]
    max_height = image.shape[0]

    heat_values = []
    for i in range(max_width * max_height):
        heat_values.append(0.0)

    for idx in range(len(coordinates_array)):
        coordinates = coordinates_array[idx]
        time_stamps = utils.get_element_or_none(time_stamps_array, idx)
        min_idx = 0
        max_idx = len(coordinates)

        if click_settings.use_rectangle:
            for i in range(min_idx, max_idx):
                time = get_time(i, time_stamps)
                fill_for_rectangle(heat_values, coordinates[i][0], coordinates[i][1], click_settings, max_width,
                                   max_height,
                                   time)
        elif click_settings.use_circle:
            for i in range(min_idx, max_idx):
                time = get_time(i, time_stamps)
                fill_for_circle(heat_values, coordinates[i][0], coordinates[i][1], click_settings, max_width,
                                max_height,
                                time)
        elif click_settings.use_ellipse:
            for i in range(min_idx, max_idx):
                time = get_time(i, time_stamps)
                fill_for_ellipse(heat_values, coordinates[i][0], coordinates[i][1], click_settings, max_width,
                                 max_height,
                                 time)

    heat_values = np.array(heat_values)
    max = np.unique(np.sort(heat_values.flatten()))[-1]
    low = max * lower
    high = max * upper
    heat_values[heat_values < low] = 0.0
    heat_values[heat_values > high] = 0.0

    heat_values = heat_values.tolist()

    normalize_heat(heat_values)
    draw_heat(image, heat_values)

    click_settings.reset_grad_radius_to_shape()

    return heat_values