本文整理汇总了Python中picture.Picture.from_file方法的典型用法代码示例。如果您正苦于以下问题:Python Picture.from_file方法的具体用法?Python Picture.from_file怎么用?Python Picture.from_file使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类picture.Picture
的用法示例。
在下文中一共展示了Picture.from_file方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Exception
# 需要导入模块: from picture import Picture [as 别名]
# 或者: from picture.Picture import from_file [as 别名]
import importlib
from picture import Picture
if __name__ == '__main__':
# Handle command line arguments
parser = argparse.ArgumentParser()
parser.add_argument("data", help="filename for input data")
parser.add_argument("algorithm", help="filename for algorithm to use")
parser.add_argument("-i", "--iterations", help="number of iterations needed for algorithm", type=int)
parser.add_argument("-d", "--debug", dest='debug', action='store_true')
args = parser.parse_args()
# Load input data and algorithm
picture = Picture.from_file(args.data)
module = importlib.import_module('algorithms.' + args.algorithm)
# Get result from the algorithm
painter = module.algorithm(picture, args)
if args.debug:
# Output images and other details
print(picture)
print(painter.picture)
print(len(painter.commands))
if (picture != painter.picture).any():
raise Exception("Result image different from target image")
else:
# Output commands
print(painter.get_output())