Esempio n. 1
0
def main_test():
	conf = config.Conf(sys.argv[1])

	setup_work_dir ( conf.images_dir, conf.work_dir, conf.min_images_dir, conf.images_size, conf.px_images_dir )

	ph = Mosaic(size=conf.mosaic_size)
	photo_list = PhotoList(conf.px_images_dir)

	photo_list.sort_by_brightness()
	nb_light_photos = ph.get_border_length(0) + ph.get_border_length(1) + ph.get_border_length(2) + ph.get_border_length(3)
	nb_dark_photos = ph.get_border_length(4)

	dark_photo_list = photo_list[0:nb_dark_photos]
	light_photo_list = photo_list[len(photo_list)-nb_light_photos:]

	random.shuffle(dark_photo_list)
	random.shuffle(light_photo_list)

	ph.add_border ( light_photo_list, 0 )
	del(light_photo_list[0:ph.get_border_length(0)])
	ph.add_border ( light_photo_list, 1 )
	del(light_photo_list[0:ph.get_border_length(1)])
	ph.add_border ( light_photo_list, 2 )
	del(light_photo_list[0:ph.get_border_length(2)])
	ph.add_border ( light_photo_list, 3 )

	ph.add_border ( dark_photo_list, 4 )

	photo_list.report_min_usage(conf.work_dir+"photos.used.log")

	imagelib.montage ( (ph.width, ph.height), conf.images_size,
	                   list(ph.list_generator(conf.min_images_dir)),
	                   conf.work_dir+"out.jpg" )
Esempio n. 2
0
def main_mosaic():
	conf = config.Conf(sys.argv[1])

	setup_work_dir ( conf.images_dir, conf.work_dir, conf.min_images_dir, conf.images_size, conf.px_images_dir )

	ph = Mosaic(image=conf.work_dir+"/pix.jpg")
	photo_list = PhotoList(conf.px_images_dir)

	ph.fill(photo_list, max_photo_usage=conf.max_usage)
	ph.add_missing(photo_list, min_photo_usage=conf.min_usage)
	ph.write_im_script(conf.work_dir+"montage.sh", conf.work_dir+"mosaique.log")
	photo_list.report_min_usage(conf.work_dir+"photos.used.log")
	ph.report_distance(conf.work_dir+"distance.log")

	imagelib.montage ( (ph.width, ph.height), conf.images_size, list(ph.list_generator(conf.min_images_dir)), conf.work_dir+"out.jpg" )

	resized_image_file = conf.work_dir+"/resized.jpg"
	imagelib.resize( conf.mosaic_image, resized_image_file, conf.total_size )
	imagelib.blend( resized_image_file, conf.work_dir+"out.jpg", conf.out_file_name, conf.surimp )