def draw_horizontal_heat_map(image, coordinates, click_settings, min_idx=None, max_idx=None, time_stamps=None, should_copy=False): """ :param time_stamps: value for timestamps if it should be used :param image: the image data to work with :param min_idx: the index where to start drawing the heatmap :param max_idx: the index where to stop drawing the heatmap exclusive :param coordinates: an array of coordinates (x,y) :param click_settings: the click Settings of the Image :param should_copy: Indicates if the image should be copied b4 :return: the modified image data """ im = utils.shallow_or_deep(image, should_copy) min_idx = utils.get_normal_on_none(min_idx, 0) min_idx = utils.clamp(min_idx, 0, len(coordinates) - 1) max_idx = utils.get_normal_on_none(max_idx, len(coordinates)) max_idx = utils.clamp(max_idx, 1, len(coordinates)) hmh.draw_horizontal_heatmap(im, min_idx, max_idx, coordinates, time_stamps, click_settings) return im
def draw_row_view(image, coordinate, click_settings, should_copy=False): """ :param image: the image data to work on :param coordinate: the coordinate where to draw around as tuple (x,y) :param click_settings: the clickSettings :param should_copy: Indicates if the image should be copied b4 :return: the manipulated image data """ im = utils.shallow_or_deep(image, should_copy) x = coordinate[0] minimal_x_half = click_settings.minimal_width + click_settings.grad_radius im = drw.draw_line(im, (max(0, x - minimal_x_half), 0), (max(0, x - minimal_x_half), image.shape[0] - 1), (0, 0, 0, 1)) im = drw.draw_line( im, (min(image.shape[1] - 1, x + minimal_x_half), 0), (min(image.shape[1] - 1, x + minimal_x_half), image.shape[0] - 1), (0, 0, 0, 1)) return im
def draw_horizontal_needleman_wunsch_line_diagram(image, rounding, coordinate_buffer_a, coordinate_buffer_b, should_copy=False): """ :param image: image data to draw on :param rounding: rounding value :param coordinate_buffer_a: coordinates of the first buffer [(x,y)] :param coordinate_buffer_b: coordinates of the second buffer [(x,y)] :param should_copy: Indicates if the image should be copied b4 :return: the updated image, the buffer with needleman wunsch data (dictionary with "kind", "data") """ im = utils.shallow_or_deep(image, should_copy) buffer_nw_a = [] buffer_nw_b = [] rounding_half = rounding / 2 for i in range(0, len(coordinate_buffer_a)): buffer_nw_a.append( nw.round_with_offset(rounding_half, rounding, coordinate_buffer_a[i][0])) for i in range(0, len(coordinate_buffer_b)): buffer_nw_b.append( nw.round_with_offset(rounding_half, rounding, coordinate_buffer_b[i][0])) solution = nw.needleman_wunsch(buffer_nw_a, buffer_nw_b) color = (0, 0, 0, 1) current_x = solution[0]["data"] current_y = 3 for i in range(0, len(solution)): if solution[i]["kind"] == "delete" or solution[i][ "kind"] == "missmatch": continue x = solution[i]["data"] im = drw.draw_line(im, (current_x, current_y), (x, current_y), color) current_x = x im = drw.draw_line(im, (current_x, current_y), (current_x, current_y + 3), color) current_y += 3 return im, solution
def draw_vertical_combined_needleman_wunsch_semantic_line_diagram( image, buffers, semantic_classifier, should_copy=False): """ :param image: image data to draw on :param buffers: a buffer of coordinate lists :param should_copy: Indicates if the image should be copied b4 :param semantic_classifier The semantic classifiers class for rounding :return: the updated image, the buffer with needleman wunsch data (dictionary with "kind", "data") """ im = utils.shallow_or_deep(image, should_copy) semantic_buffers = [] for buffer in buffers: semantic_buffers.append( semantic_classifier.align_buffer_to_classifier(buffer)) return draw_vertical_combined_needleman_wunsch_line_diagram( im, 1, semantic_buffers)
def draw_vertical_combined_needleman_wunsch_line_diagram( image, rounding, buffers, should_copy=False): """ :param image: image data to draw on :param rounding: rounding value :param buffers: a buffer of coordinate lists :param should_copy: Indicates if the image should be copied b4 :return: the updated image data and the solution of the needleman wunsch """ im = utils.shallow_or_deep(image, should_copy) buffers_needle = [] rounding_half = rounding / 2 for i in range(0, len(buffers)): tmp_buffer = [] for j in range(0, len(buffers[i])): tmp_buffer.append( nw.round_with_offset(rounding_half, rounding, buffers[i][j][1])) buffers_needle.append(tmp_buffer) current_solution = buffers_needle[0] for i in range(1, len(buffers_needle)): sol_buffer = nw.needleman_wunsch(buffers_needle[i], current_solution) current_solution = nw.to_usable_buffer(sol_buffer) color = (0, 0, 0, 1) current_x = 3 current_y = current_solution[0] for i in range(0, len(current_solution)): y = current_solution[i] im = drw.draw_line(im, (current_x, current_y), (current_x, y), color) current_y = y im = drw.draw_line(im, (current_x, current_y), (current_x + 3, current_y), color) current_x += 3 return im, current_solution
def draw_semantic_classifier(image, semantic_classifier, should_copy=False): """ :param image: image data to draw on :param semantic_classifier: the semantic classifer object to draw :param should_copy: Indicates if the image should be copied b4 :return: the updated image data and the solution of the needleman wunsch """ im = utils.shallow_or_deep(image, should_copy) semantic_fields = semantic_classifier.get_semantic_fields() for field in semantic_fields: if field[1] < im.shape[0]: im = drw.draw_line(im, (0, field[1]), (image.shape[1] - 1, field[1]), (0, 0, 0, 1)) x = image.shape[1] - 12 y = field[0] + 3 drw.draw_letter(im, (x, y), field[2][0]) return im
def draw_vertical_needleman_wunsch_semantic_line_diagram( image, coordinate_buffer_a, coordinate_buffer_b, semantic_classifier, should_copy=False): """ :param image: image data to draw on :param coordinate_buffer_a: coordinates of the first buffer [(x,y)] :param coordinate_buffer_b: coordinates of the second buffer [(x,y)] :param should_copy: Indicates if the image should be copied b4 :param semantic_classifier The semantic classifiers class for rounding :return: the updated image, the buffer with needleman wunsch data (dictionary with "kind", "data") """ im = utils.shallow_or_deep(image, should_copy) semantic_coord_a = semantic_classifier.align_buffer_to_classifier( coordinate_buffer_a) semantic_coord_b = semantic_classifier.align_buffer_to_classifier( coordinate_buffer_b) return draw_vertical_needleman_wunsch_line_diagram(im, 1, semantic_coord_a, semantic_coord_b)
def draw_horizontal_line_diagram(image, coordinates, min_idx=None, max_idx=None, should_copy=False): """ :param image: the image data to work with :param min_idx: the index where to start drawing the heatmap :param max_idx: the index where to stop drawing the heatmap exclusive :param coordinates: an array of coordinates (x,y) :param should_copy: Indicates if the image should be copied b4 :return: the modified image data """ im = utils.shallow_or_deep(image, should_copy) min_idx = utils.get_normal_on_none(min_idx, 0) min_idx = utils.clamp(min_idx, 0, len(coordinates) - 1) max_idx = utils.get_normal_on_none(max_idx, len(coordinates)) max_idx = utils.clamp(max_idx, 1, len(coordinates)) # a number to start, 3 otherwise would overlap with the start current_y = 3 current_x = coordinates[min_idx][0] for i in range(min_idx, max_idx): x = coordinates[i][0] im = drw.draw_line(im, (current_x, current_y), (x, current_y), (0, 0, 0, 1)) current_x = x im = drw.draw_line(im, (current_x, current_y), (current_x, current_y + 3), (0, 0, 0, 1)) current_y += 3 return im
def draw_average_shape_heat_map_rel(image, coordinates_array, click_settings, upper, lower, time_stamps_array=None, should_copy=False): """ draws a heatmap based on the nth largest value in the heatmap :param upper: :param image: :param coordinates_array: :param click_settings: :param lower: :param time_stamps_array: :param should_copy: :return: """ im = utils.shallow_or_deep(image, should_copy) heatmask = hmh.draw_average_heat_map_rel(im, coordinates_array, click_settings, time_stamps_array, upper, lower) return im, heatmask