diff --git a/.gitignore b/.gitignore index b53545f..0b6dcd0 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ examples/blur examples/dither examples/edd examples/img2rubik +examples/sharpen test/u8tof32tou8 stamp-h1 .auto diff --git a/examples/Makefile.am b/examples/Makefile.am index 81d8799..ef5dcc8 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -2,7 +2,7 @@ AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/pipi -bin_PROGRAMS = blur dither edd img2rubik +bin_PROGRAMS = blur dither edd img2rubik sharpen blur_SOURCES = blur.c blur_LDADD = ../pipi/libpipi.la @@ -16,3 +16,6 @@ edd_LDADD = ../pipi/libpipi.la img2rubik_SOURCES = img2rubik.c img2rubik_LDADD = ../pipi/libpipi.la +sharpen_SOURCES = sharpen.c +sharpen_LDADD = ../pipi/libpipi.la + diff --git a/examples/sharpen.c b/examples/sharpen.c new file mode 100644 index 0000000..3218e3e --- /dev/null +++ b/examples/sharpen.c @@ -0,0 +1,43 @@ +#include "config.h" +#include "common.h" + +#include +#include +#include + +#include + +double kern[] = +{ + 0., -.0625, -.125, -.0625, 0., + -.0625, -.125, -.25, -.125, -.0625, + -.125, -.25, 3.5, -.25, -.125, + -.0625, -.125, -.25, -.125, -.0625, + 0., -.0625, -.125, -.0625, 0., +}; + +int main(int argc, char *argv[]) +{ + char *srcname = NULL, *dstname = NULL; + pipi_image_t *img, *newimg; + + if(argc < 3) + { + fprintf(stderr, "%s: too few arguments\n", argv[0]); + fprintf(stderr, "Usage: %s \n", argv[0]); + return EXIT_FAILURE; + } + + srcname = argv[1]; + dstname = argv[2]; + + img = pipi_load(srcname); + newimg = pipi_convolution(img, 5, 5, kern); + pipi_free(img); + + pipi_save(newimg, dstname); + pipi_free(newimg); + + return 0; +} +