Esempio n. 1
0
def random_processing(image):
	for i in range(config.RANDOM_NVERSIONS):
		r = random.randint(0, 2)
		print r
		if r == 0:
			processed_image = ip.monochrome(image, config.random_color(), 100)
			# processed_image = ip.monochrome(image, config.random_color(), int(random.gauss(100, 30)))
		if r == 1:
			processed_image = ip.bloodyface(image)
		if r == 2:
			gain = abs(random.gauss(2, 1))
			mode_size = sample(range(3, 33, 2), 1)[0]
			processed_image = ip.sketch(image, gain = gain, mode_size = mode_size)
		processed_image = ie.random_resize(processed_image, config.RANDOM_SCALING_ALPHA, config.RANDOM_SCALING_GAMMA)

		image_path = save_image(processed_image)
		url = URL_BASE + '/upload_random_image'
		upload_image(image_path, url)			
Esempio n. 2
0
def grid_processing(image):
	width, height = config.GRID_IMAGE_SIZE
	for i in range(config.GRID_NVERSION):	
		if args.grid_processing == 'sketch':
			# gain = abs(random.gauss(2, 1))
			# mode_size = sample(range(3, 33, 2), 1)[0]
			gain = 1
			mode_size = 11
			processed_image = ip.sketch(image, gain = gain, mode_size = mode_size)	
			processed_image = ie.resize_to_size(processed_image, width, height)
			image_path = save_image(processed_image)
			upload_image(image_path, URL_BASE + '/upload_grid_image_sketch')
		elif args.grid_processing == 'monochrome':
			# processed_image_white = ip.monochrome(image, config.random_color(), 130)
			# processed_image_white = ie.resize_to_size(processed_image_white, width, height)
			# image_path_white = save_image(processed_image_white)
			# upload_image(image_path_white, URL_BASE + '/upload_grid_image_white')

			processed_image_black = ip.monochrome(image, config.random_color(), 130, white_background = False)
			processed_image_black = ie.resize_to_size(processed_image_black, width, height)
			image_path_black = save_image(processed_image_black)
			upload_image(image_path_black, URL_BASE + '/upload_grid_image_black')