| Revision 2654,
1.2 KB
checked in by sam, 5 years ago
(diff) |
- ostromoukhov.c: Ostromoukhov's simple error diffusion algorithm.
|
| Line | |
|---|
| 1 | #include "config.h" |
|---|
| 2 | #include "common.h" |
|---|
| 3 | |
|---|
| 4 | #include <stdio.h> |
|---|
| 5 | #include <stdlib.h> |
|---|
| 6 | #include <string.h> |
|---|
| 7 | |
|---|
| 8 | #include <pipi.h> |
|---|
| 9 | |
|---|
| 10 | int main(int argc, char *argv[]) |
|---|
| 11 | { |
|---|
| 12 | char *srcname = NULL, *dstname = NULL; |
|---|
| 13 | pipi_image_t *img, *newimg; |
|---|
| 14 | |
|---|
| 15 | if(argc < 3) |
|---|
| 16 | { |
|---|
| 17 | fprintf(stderr, "%s: too few arguments\n", argv[0]); |
|---|
| 18 | fprintf(stderr, "Usage: %s <src> <method> <dest>\n", argv[0]); |
|---|
| 19 | fprintf(stderr, "Where <method> is one of:\n"); |
|---|
| 20 | fprintf(stderr, " 1 Floyd-Steinberg (serpentine)\n"); |
|---|
| 21 | fprintf(stderr, " 2 Ostromoukhov (serpentine)\n"); |
|---|
| 22 | fprintf(stderr, " 3 Direct binary search\n"); |
|---|
| 23 | return EXIT_FAILURE; |
|---|
| 24 | } |
|---|
| 25 | |
|---|
| 26 | srcname = argv[1]; |
|---|
| 27 | dstname = argv[3]; |
|---|
| 28 | |
|---|
| 29 | img = pipi_load(srcname); |
|---|
| 30 | pipi_getpixels(img, PIPI_PIXELS_RGBA_F); |
|---|
| 31 | |
|---|
| 32 | switch(atoi(argv[2])) |
|---|
| 33 | { |
|---|
| 34 | case 3: |
|---|
| 35 | newimg = pipi_dbs(img); break; |
|---|
| 36 | case 2: |
|---|
| 37 | newimg = pipi_ostromoukhov(img); break; |
|---|
| 38 | case 1: |
|---|
| 39 | default: |
|---|
| 40 | newimg = pipi_floydsteinberg(img); break; |
|---|
| 41 | } |
|---|
| 42 | |
|---|
| 43 | pipi_free(img); |
|---|
| 44 | |
|---|
| 45 | pipi_getpixels(newimg, PIPI_PIXELS_RGBA_F); |
|---|
| 46 | pipi_save(newimg, dstname); |
|---|
| 47 | pipi_free(newimg); |
|---|
| 48 | |
|---|
| 49 | return 0; |
|---|
| 50 | } |
|---|
| 51 | |
|---|
Note: See
TracBrowser
for help on using the repository browser.