aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md28
-rw-r--r--src/main.c30
2 files changed, 57 insertions, 1 deletions
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..4a2bdab
--- /dev/null
+++ b/README.md
@@ -0,0 +1,28 @@
+# Dsco
+
+A simple ppm image processor, that use convolution to transform images
+
+## Usage
+
+If `INPUT` is not specified the program will use standard input.
+
+```
+Usage:
+ dsco [INPUT] -f [edge|blur|sharpen] [-o OUTPUT]
+
+Options:
+ -o output file [default: /dev/stdout]
+ -f filter to use
+
+ edge: -1 -1 -1
+ -1 8 -1
+ -1 -1 -1
+
+ sharpen: 0 -1 0
+ -1 5 -1
+ 0 -1 0
+
+ blur: 1 2 1
+ 1/16 2 4 2
+ 1 2 1
+```
diff --git a/src/main.c b/src/main.c
index 370ece8..add73f7 100644
--- a/src/main.c
+++ b/src/main.c
@@ -15,10 +15,36 @@ static void usage(void);
void
usage(void)
{
- fprintf(stderr, "Usage: dsco [INPUT] -f [edge|blur] [-o OUTPUT]\n");
+ fprintf(stderr, "Usage: dsco [INPUT] -f [edge|blur|sharpen] [-o OUTPUT]\n");
exit(1);
}
+void
+help(void)
+{
+ fprintf(stdout,
+ "Usage:\n"
+ " dsco [INPUT] -f [edge|blur|sharpen] [-o OUTPUT]\n"
+ "\n"
+ "Options:\n"
+ " -o output file [default: /dev/stdout] \n"
+ " -f filter to use\n"
+ "\n"
+ " edge: -1 -1 -1\n"
+ " -1 8 -1\n"
+ " -1 -1 -1\n"
+ "\n"
+ " sharpen: 0 -1 0\n"
+ " -1 5 -1\n"
+ " 0 -1 0\n"
+ "\n"
+ " blur: 1 2 1\n"
+ " 1/16 2 4 2\n"
+ " 1 2 1\n"
+ );
+ exit(0);
+}
+
Image
image_convolution(Image input, float kernel[9])
{
@@ -138,6 +164,8 @@ int main(int argc, char *argv[])
case 0:
in_file = cli_arg;
break;
+ case 'h':
+ help();
default:
usage();
}
Feel free to download, copy and edit any repo