def __main__(filename, choice_save):
    blackcolor = (0, 0, 0)
    list_of_colors = [(218, 165, 32), (205, 133, 63), (210, 105, 30),
                      (139, 69, 19), (160, 82, 45), (165, 42, 42),
                      (128, 0, 0)]  #lista de colores
    original_image = Image.open(filename)
    rgb_image = original_image.convert('RGB')
    image = pix.grayscale_image(rgb_image)
    food_image = buscar_croquetas(rgb_image, list_of_colors)
    frec_colors = pix.frec_colors(food_image)
    xs, ys = food_image.size
    total_pixels = xs * ys
    black_frec = frec_colors[blackcolor]
    black_porc = (black_frec * 100) / float(total_pixels)
    print "Porcentaje: ", black_porc, "%"
    if black_porc >= 75.0:
        print "Exceso de comida"
    elif black_porc >= 55.0:
        print "Suficiente comida"
    elif black_porc > 20.0:
        print "Insuficiente comida, no seas mal amo"
    else:
        print "Eres una escoria"
    if choice_save[0]:
        bool_save = files.validate_save("carepet\\", choice_save[1], '.png')
        if bool_save[0]:
            print "Directory of the new image: {}".format(bool_save[1])
            food_image.save(bool_save[1])
    return None
def __main__(filename, choice_info, choice_save):
	bool_info = False
	choice_info = False #dummy
	original_image = Image.open(filename)
	ellipse_image = define_ellipses(original_image)
	ellipse_image.show()
	if choice_save[0]:
		bool_save =  files.validate_save("ellipses\output\\", choice_save[1], '.png')
		if bool_save[0]:
			print "Directory of the new image: {}".format(bool_save[1])
			ellipse_image.save(bool_save[1])			
	return None
Example #3
0
def __main__(filename, choice_info, choice_save):
	bool_info = False
	choice_info = False #dummy
	original_image = Image.open(filename)
	rgb_image = original_image.convert('RGB')
	image = pix.grayscale_image(rgb_image)
	circle_image = define_circles(image)
	circle_image.show()
	if choice_save[0]:
		bool_save =  files.validate_save("circles\output\\", choice_save[1], '.png')
		if bool_save[0]:
			print "Directory of the new image: {}".format(bool_save[1])
			circle_image.save(bool_save[1])			
	return None
Example #4
0
def __main__(filename, choice_mask, choice_save):
    if choice_mask[0]:
        mask_to_use = choice_mask[1]
    else:
        mask_to_use = "sobeldg"  #default
    original_image = Image.open(filename)
    edge_image = define_edges(original_image, mask_to_use)
    edge_image.show()
    if choice_save[0]:
        bool_save = files.validate_save("edges\output\\", choice_save[1],
                                        '.png')
        if bool_save[0]:
            print "Directory of the new image: {}".format(bool_save[1])
            edge_image.save(bool_save[1])
    return None
Example #5
0
def __main__(filename, choice_mask, choice_save):
    if choice_mask[0]:
        mask_to_use = choice_mask[1]
    else:
        mask_to_use = None
    original_image = Image.open(filename)
    rgb_image = original_image.convert('RGB')
    image = pix.grayscale_image(rgb_image)
    bool_normalize = True
    new_pixels = apply_mask(image, mask_to_use, bool_normalize)
    new_image = pix.change_pixels(image, new_pixels)
    image.show()
    new_image.show()
    if choice_save[0]:
        bool_save = files.validate_save("samples\destination\\",
                                        choice_save[1], '.png')
        if bool_save[0]:
            print "Directory of the new image: {}".format(bool_save[1])
            new_image.save(bool_save[1])
    #new_image.show()
    return None