[77] | 1 | /* |
---|
| 2 | Copyright (C) 2006 Pedro Felzenszwalb |
---|
| 3 | |
---|
| 4 | This program is free software; you can redistribute it and/or modify |
---|
| 5 | it under the terms of the GNU General Public License as published by |
---|
| 6 | the Free Software Foundation; either version 2 of the License, or |
---|
| 7 | (at your option) any later version. |
---|
| 8 | |
---|
| 9 | This program is distributed in the hope that it will be useful, |
---|
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 12 | GNU General Public License for more details. |
---|
| 13 | |
---|
| 14 | You should have received a copy of the GNU General Public License |
---|
| 15 | along with this program; if not, write to the Free Software |
---|
| 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
| 17 | */ |
---|
| 18 | |
---|
| 19 | #include <cstdio> |
---|
| 20 | #include <cstdlib> |
---|
| 21 | #include <image.h> |
---|
| 22 | #include <misc.h> |
---|
| 23 | #include <pnmfile.h> |
---|
| 24 | #include "segment-image.h" |
---|
| 25 | |
---|
| 26 | int main(int argc, char **argv) { |
---|
| 27 | if (argc != 6) { |
---|
| 28 | fprintf(stderr, "usage: %s sigma k min input(ppm) output(ppm)\n", argv[0]); |
---|
| 29 | return 1; |
---|
| 30 | } |
---|
| 31 | |
---|
| 32 | float sigma = atof(argv[1]); |
---|
| 33 | float k = atof(argv[2]); |
---|
| 34 | int min_size = atoi(argv[3]); |
---|
| 35 | |
---|
| 36 | |
---|
| 37 | gettimeofday(&start, NULL); |
---|
| 38 | |
---|
| 39 | printf("loading input image.\n"); |
---|
| 40 | //image<rgb> *input = loadPPM(argv[4]); |
---|
| 41 | image *input = loadPPM(argv[4]); |
---|
| 42 | |
---|
| 43 | printf("processing\n"); |
---|
| 44 | int num_ccs; |
---|
| 45 | //image<rgb> *seg = segment_image(input, sigma, k, min_size, &num_ccs); |
---|
| 46 | image *seg = segment_image(input, sigma, k, min_size, &num_ccs); |
---|
| 47 | savePPM(seg, argv[5]); |
---|
| 48 | |
---|
| 49 | printf("got %d components\n", num_ccs); |
---|
| 50 | printf("done! uff...thats hard work.\n"); |
---|
| 51 | |
---|
| 52 | return 0; |
---|
| 53 | } |
---|
| 54 | |
---|