source: libpipi/trunk/examples/sharpen.c @ 2662

Last change on this file since 2662 was 2662, checked in by Sam Hocevar, 12 years ago
  • sharpen.c: add a sharpen filter example, using our generic convolution routine. Note that it is not the "real" sharpen which should be built on top of a gaussian kernel.
File size: 864 bytes
RevLine 
[2662]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
10double kern[] =
11{
12       0., -.0625, -.125, -.0625,     0.,
13   -.0625,  -.125,  -.25,  -.125, -.0625,
14    -.125,   -.25,   3.5,   -.25,  -.125,
15   -.0625,  -.125,  -.25,  -.125, -.0625,
16       0., -.0625, -.125, -.0625,     0.,
17};
18
19int main(int argc, char *argv[])
20{
21    char *srcname = NULL, *dstname = NULL;
22    pipi_image_t *img, *newimg;
23
24    if(argc < 3)
25    {
26        fprintf(stderr, "%s: too few arguments\n", argv[0]);
27        fprintf(stderr, "Usage: %s <src> <dest>\n", argv[0]);
28        return EXIT_FAILURE;
29    }
30
31    srcname = argv[1];
32    dstname = argv[2];
33
34    img = pipi_load(srcname);
35    newimg = pipi_convolution(img, 5, 5, kern);
36    pipi_free(img);
37
38    pipi_save(newimg, dstname);
39    pipi_free(newimg);
40
41    return 0;
42}
43
Note: See TracBrowser for help on using the repository browser.