-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
43 lines (34 loc) · 958 Bytes
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "seamcarving.h"
#include "c_img.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N_SEAMS 50
int main(){
//surfing image testing. Image: HJoceanSmall.bmp
struct rgb_img *im;
struct rgb_img *cur_im;
struct rgb_img *grad;
double *best;
int *path;
read_in_img(&im, "HJoceanSmall.bin");
for(int i = 0; i < N_SEAMS; i++){
printf("i = %d\n", i);
calc_energy(im, &grad);
dynamic_seam(grad, &best);
recover_path(best, grad->height, grad->width, &path);
remove_seam(im, &cur_im, path);
char filename[200];
sprintf(filename, "img%d.bin", i);
char filePath[] = "Carved-Images\\";
strcat(filePath, filename);
write_img(cur_im, filePath);
destroy_image(im);
destroy_image(grad);
free(best);
free(path);
im = cur_im;
}
destroy_image(im);
return 0;
}