def line_detection(image_name, output="output.png"): f = Filtros() imagex = f.aplicar_mascara(image_name, ["prewittx"], [1.0/10.0], cmd="i") imagey = f.aplicar_mascara(image_name, ["prewitty"], [1.0/10.0], cmd="i") image = Image.open(image_name) line_matrix, frequency = calculate_line_values(imagex, imagey, image, saltos_ro=5, saltos_angulo=5, bias=10.0) for i in frequency.keys(): if frequency[i] < 5: frequency.pop(i) draw_lines(image, frequency, line_matrix) image.save(output)
def circle_detection(image_name, output="output.png"): f = Filtros() imagex = f.aplicar_mascara(image_name, ["sobelx"], [1.0/10.0], cmd="i") imagey = f.aplicar_mascara(image_name, ["sobely"], [1.0/10.0], cmd="i") # imagex = f.aplicar_mascara(image_name, ["prewittx"], [1.0/10.0], cmd="i") # imagey = f.aplicar_mascara(image_name, ["prewitty"], [1.0/10.0], cmd="i") image = Image.open(image_name) salto = 30 circle_matrix, frequency = calculate_circle_center(imagex, imagey, image, salto = salto, bias=10.0) for i in frequency.keys(): if frequency[i] < salto*8: frequency.pop(i) else: print frequency[i], i draw_lines(image, frequency, circle_matrix) image.save(output)
def line_detection(image_name, output="output.png"): f = Filtros() imagex = f.aplicar_mascara(image_name, ["prewittx"], [1.0/18.0], cmd="i") imagey = f.aplicar_mascara(image_name, ["prewitty"], [1.0/18.0], cmd="i") image = Image.open(image_name) line_matrix, frequency = calculate_line_values(imagex, imagey, image, saltos_ro=5, saltos_angulo=5, bias=10.0) # print "numero de grupos:", len(frequency.keys()) f = list() for i in frequency.keys(): if frequency[i] < 5: frequency.pop(i) else: f.append(frequency[i]) f.sort() # for i in f: # print i draw_lines(image, frequency, line_matrix) image.save(output)