| Revision 2809,
996 bytes
checked in by jylam, 5 years ago
(diff) |
- Preliminary image histogram routines and example
|
| 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, *tmp; |
|---|
| 14 | pipi_histogram_t* histogram; |
|---|
| 15 | int ret = 0; |
|---|
| 16 | if(argc < 2) |
|---|
| 17 | { |
|---|
| 18 | fprintf(stderr, "%s: too few arguments\n", argv[0]); |
|---|
| 19 | fprintf(stderr, "Usage: %s <src> <dest>\n", argv[0]); |
|---|
| 20 | return EXIT_FAILURE; |
|---|
| 21 | } |
|---|
| 22 | |
|---|
| 23 | srcname = argv[1]; |
|---|
| 24 | dstname = argv[2]; |
|---|
| 25 | |
|---|
| 26 | img = pipi_load(srcname); |
|---|
| 27 | |
|---|
| 28 | if(!img) { |
|---|
| 29 | fprintf(stderr, "Can't open %s for reading\n", srcname); |
|---|
| 30 | } |
|---|
| 31 | |
|---|
| 32 | newimg = pipi_copy(img); |
|---|
| 33 | pipi_free(img); |
|---|
| 34 | |
|---|
| 35 | |
|---|
| 36 | tmp = pipi_copy(newimg); |
|---|
| 37 | |
|---|
| 38 | histogram = pipi_new_histogram(); |
|---|
| 39 | pipi_get_image_histogram(tmp, histogram, PIPI_COLOR_R|PIPI_COLOR_G|PIPI_COLOR_B); |
|---|
| 40 | |
|---|
| 41 | |
|---|
| 42 | pipi_render_histogram(tmp, histogram, PIPI_COLOR_R|PIPI_COLOR_G|PIPI_COLOR_B); |
|---|
| 43 | |
|---|
| 44 | pipi_save(tmp, dstname); |
|---|
| 45 | pipi_free(newimg); |
|---|
| 46 | |
|---|
| 47 | return ret; |
|---|
| 48 | } |
|---|
| 49 | |
|---|
Note: See
TracBrowser
for help on using the repository browser.