summaryrefslogtreecommitdiffstats
path: root/options.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2014-08-07 16:14:01 -0400
committerTavian Barnes <tavianator@tavianator.com>2014-08-07 16:14:01 -0400
commitf4481d9956fa8e3f3022bedaea07a37c02ad6b22 (patch)
tree5532df423a3cf74332f94a108e740eed70d4499f /options.c
parent1865067cbbb02c3bb5c27cee18d134cc19bbe0b3 (diff)
downloadkd-forest-f4481d9956fa8e3f3022bedaea07a37c02ad6b22.tar.xz
Support average selection.
Diffstat (limited to 'options.c')
-rw-r--r--options.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/options.c b/options.c
index 04f1f82..06deddb 100644
--- a/options.c
+++ b/options.c
@@ -226,6 +226,7 @@ print_usage(FILE *file, const char *command)
usage("Usage:\n");
usage(" !$! *%s* [-b|--bit-depth @DEPTH@]\n", command);
usage(" %s [-s|--hue-sort] [-r|--random]\n", whitespace);
+ usage(" %s [-l|--selection @min@|@mean@]\n", whitespace);
usage(" %s [-c|--color-space @RGB@|@Lab@|@Luv@]\n", whitespace);
usage(" %s [-a|--animate]\n", whitespace);
usage(" %s [-o|--output @PATH@]\n", whitespace);
@@ -238,6 +239,10 @@ print_usage(FILE *file, const char *command)
usage(" Sort colors by hue first (!default!)\n");
usage(" -r, --random:\n");
usage(" Randomize colors first\n\n");
+ usage(" -l, --selection @min@|@mean@:\n");
+ usage(" Specify the selection mode (!default!: @min@)\n\n");
+ usage(" @min@: Pick the pixel with the closest neighboring pixel\n");
+ usage(" @mean@: Pick the pixel with the closest average of all its neighbors\n\n");
usage(" -c, --color-space @RGB@|@Lab@|@Luv@:\n");
usage(" Use the given color space (!default!: @Lab@)\n\n");
usage(" -a, --animate:\n");
@@ -259,10 +264,11 @@ parse_options(options_t *options, int argc, char *argv[])
// Set defaults
options->bit_depth = 24;
options->mode = MODE_HUE_SORT;
- options->seed = 0;
+ options->selection = SELECTION_MIN;
options->color_space = COLOR_SPACE_LAB;
options->animate = false;
options->filename = NULL;
+ options->seed = 0;
options->help = false;
bool result = true;
@@ -282,15 +288,19 @@ parse_options(options_t *options, int argc, char *argv[])
options->mode = MODE_HUE_SORT;
} else if (parse_arg(argc, argv, "-r", "--random", NULL, &i, &error)) {
options->mode = MODE_RANDOM;
- } else if (parse_arg(argc, argv, "-e", "--seed", &value, &i, &error)) {
- if (!str_to_uint(value, &options->seed)) {
- fprintf(stderr, "Invalid random seed: `%s'\n", value);
- error = true;
- }
} else if (parse_arg(argc, argv, "-a", "--animate", NULL, &i, &error)) {
options->animate = true;
} else if (parse_arg(argc, argv, "-o", "--output", &value, &i, &error)) {
options->filename = value;
+ } else if (parse_arg(argc, argv, "-l", "--selection", &value, &i, &error)) {
+ if (strcmp(value, "min") == 0) {
+ options->selection = SELECTION_MIN;
+ } else if (strcmp(value, "mean") == 0) {
+ options->selection = SELECTION_MEAN;
+ } else {
+ fprintf(stderr, "Invalid selection mode: `%s'\n", value);
+ error = true;
+ }
} else if (parse_arg(argc, argv, "-c", "--color-space", &value, &i, &error)) {
if (strcmp(value, "RGB") == 0) {
options->color_space = COLOR_SPACE_RGB;
@@ -300,6 +310,12 @@ parse_options(options_t *options, int argc, char *argv[])
options->color_space = COLOR_SPACE_LUV;
} else {
fprintf(stderr, "Invalid color space: `%s'\n", value);
+ error = true;
+ }
+ } else if (parse_arg(argc, argv, "-e", "--seed", &value, &i, &error)) {
+ if (!str_to_uint(value, &options->seed)) {
+ fprintf(stderr, "Invalid random seed: `%s'\n", value);
+ error = true;
}
} else if (parse_arg(argc, argv, "-h", "--help", NULL, &i, &error)) {
options->help = true;