educelab.imgproc.pipeline

Utilities for building processing pipelines on the command line.

import argparse
import imageio.v3 as iio
from educelab.imgproc import pipeline

# setup the parser
parser = argparse.ArgumentParser()
parser.add_argument('--input', '-i', help='image path')
enhance_opts = pipeline.add_parser_enhancement_group(parser)

# parse arguments and commands
# foo.py -i image.png -- -gamma=0.45 -pstretch=0,99 -sharpen
args = parser.parse_args()
apply_pipeline, _ = pipeline.parse_and_build(args.commands)

# process the image
img = iio.imread(args.input)
img = apply_pipeline(img)
class educelab.imgproc.pipeline.Parsers

cmdparse namespace for parsing enhancement command arguments.

educelab.imgproc.pipeline.add_parser_enhancement_group(parser)

Adds the enhancement commands group and positional arguments to the given parser.

educelab.imgproc.pipeline.build_pipeline(cmd_list: CommandList) Pipeline

Convert parsed commands into an enhancement pipeline function.

Parameters:

cmd_list – Parsed command list.

Returns:

Pipeline callable function.

educelab.imgproc.pipeline.parse_and_build(cmd_strs: CommandStrList) Tuple[TypeAliasForwardRef('Pipeline'), TypeAliasForwardRef('CommandList')]

Parse command arguments and build the pipeline function.

Parameters:

cmd_strs – List of commands returned by argparse.

Returns:

Pipeline callable function, parsed command list.