Ejemplo n.º 1
0
    The crop area is defined by the (X, Y) top-left corner and the WIDTH and HEIGHT arguments.
    All arguments understand supported units.
    """

    lines.crop(x, y, x + width, y + height)
    return lines


@cli.command(group="Operations")
@click.argument("margin_x", type=vp.LengthType(), required=True)
@click.argument("margin_y", type=vp.LengthType(), required=True)
@click.option(
    "-l",
    "--layer",
    type=vp.LayerType(accept_multiple=True),
    default="all",
    help="Target layer(s).",
)
@vp.global_processor
def trim(document: vp.Document, margin_x: float, margin_y: float,
         layer: Union[int, List[int]]) -> vp.Document:
    """Trim the geometries by some margin.

    This command trims the geometries by the provided X and Y margins with respect to the
    current bounding box.

    By default, `trim` acts on all layers. If one or more layer IDs are provided with the
    `--layer` option, only these layers will be affected. In this case, the bounding box is
    that of the listed layers.
    """
Ejemplo n.º 2
0
@click.option(
    "-kdt",
    "--kdtree_searcher",
    is_flag=True,
    help=
    "Use exact nearest neighbor search with kdtree (slower, but more precise)")
@click.option(
    "--cmyk",
    is_flag=True,
    help=
    "Split image to CMYK and process each channel separately.  The results are in consecutively numbered layers, starting from `layer`."
)
@click.option(
    "-l",
    "--layer",
    type=vp.LayerType(accept_new=True),
    default=None,
    help=
    "Target layer or 'new'.  When CMYK enabled, this indicates the first (cyan) layer.",
)
@vp.global_processor
def vpype_flow_imager(document, layer, filename, noise_coeff, n_fields,
                      min_sep, max_sep, min_length, max_length, max_size, seed,
                      flow_seed, search_ef, test_frequency, field_type,
                      transparent_val, transparent_mask, edge_field_multiplier,
                      dark_field_multiplier, kdtree_searcher, cmyk):
    """
    Generate flowline representation from an image.

    The generated flowlines are in the coordinates of the input image,
    resized to have dimensions at most `--max_size` pixels.