def crop(image):
	w, h = image.size
	radius = int(h * 0.9 / 2)
	mw = w / 2
	mh = h / 2
	logger.debug('Cropping image from %s to %s'%(image.size, (radius * 2, radius * 2)))
	box = (mw - radius, mh - radius, mw + radius, mh + radius)
	return image.crop(box)
def resize(image, constant_scale_factor = 0.25, scale_bound_low = 0.1, scale_bound_high = 0.5, random_scaling = False):
	if random_scaling: 
		scaling = math.log(1 + scale_bound_low + random.random() * (scale_bound_high - scale_bound_low))
	else: 
		scaling = constant_scale_factor
	dim = list(image.size)
	new_dim = tuple(map(lambda x: int(x * float(scaling)), dim))
	logger.debug('Resizing image by factor %s from %s to %s'%(scaling, dim, new_dim))
	return image.resize(new_dim, Image.ANTIALIAS)
def resize_to_size(image, width, height):
	logger.debug('Resizing image by factor from %s to %s'%(image.size, (width, height)))
	return image.resize((width, height), Image.ANTIALIAS)