Skip to content

Commit

Permalink
feat(cli): expose the greedy assignment algorithm in the CLI
Browse files Browse the repository at this point in the history
closes #35
  • Loading branch information
loiccoyle committed Jan 21, 2025
1 parent be0380a commit 975ef28
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ usage: phomo [-h] [-o OUTPUT] [-c MASTER_CROP_RATIO]
[-S TILE_SIZE [TILE_SIZE ...]] [-n N_APPEARANCES] [-b] [-g]
[-d SUBDIVISIONS [SUBDIVISIONS ...]] [-G]
[-m {greyscale,norm,luv_approx}] [-j WORKERS] [-e]
[--match-master-to-tiles] [--match-tiles-to-master] [-v]
[--match-master-to-tiles] [--match-tiles-to-master] [--greedy]
[-v]
master tile_dir

positional arguments:
Expand Down Expand Up @@ -102,6 +103,8 @@ options:
--match-tiles-to-master
Match the tile images' colour distribution with the
master image colours.
--greedy Use a greedy tile assignment algorithm. Should improve
performance at the expense of accuracy.
-v, --verbose Verbosity.
```

Expand Down
9 changes: 8 additions & 1 deletion phomo/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ def parse_args(args: List[str]) -> argparse.Namespace:
help="Match the tile images' colour distribution with the master image colours.",
action="store_true",
)
parser.add_argument(
"--greedy",
help="Use a greedy tile assignment algorithm. Should improve performance at the expense of accuracy.",
action="store_true",
)
parser.add_argument(
"-v",
"--verbose",
Expand Down Expand Up @@ -213,7 +218,9 @@ def main():
if not args.gpu
else mosaic.d_matrix_cuda(metric=args.metric)
)
mosaic_im = mosaic.build(d_matrix)
mosaic_im = (
mosaic.build_greedy(d_matrix) if args.greedy else mosaic.build(d_matrix)
)
if args.output is None:
mosaic_im.show()
else:
Expand Down

0 comments on commit 975ef28

Please sign in to comment.