-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathmain.cpp
More file actions
72 lines (71 loc) · 1.46 KB
/
Copy pathmain.cpp
File metadata and controls
72 lines (71 loc) · 1.46 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include"Image.h"
int main( int argc, char *argv[])
{
char guidfile[200];
char dstfile[200];
char outfile[200];
int radius;
float thresh=1;
float eps;
int Iter=1;
Mat guid;
Mat target;
Mat out;
#if 1
if(argc<6||argc>8)
{
cout<<"SGF command format:"<<endl;
cout<<"./SGF [guid] [target] [output] [radius] [eps (0~1)] [thresh (0~1)] [iterations]"<<endl;
cout<<"The last two parameters can be neglected. Default: 1"<<endl;
exit(0);
}
if(argc>=6)
{
sprintf(guidfile,"%s",argv[1]);
sprintf(dstfile,"%s",argv[2]);
sprintf(outfile,"%s",argv[3]);
radius=atoi(argv[4]);
eps=atof(argv[5]);
}
if(argc>=7)
{
thresh=atof(argv[6]);
}
if(argc==8)
{
Iter=atoi(argv[7]);
}
#else
sprintf(guidfile,"1.png");
sprintf(dstfile,"1.png");
sprintf(outfile,"out.png");
radius=25;
eps=0.06;
Iter=10;
#endif
Image img;
guid=imread(guidfile,1);
//imwrite("guid.png",guid);
target=imread(dstfile,-1);
//cout<<target.channels();
if(target.channels()>=3)
target=imread(dstfile,1);
if(Iter==1)
{
if(target.channels()>=3)
out=img.FilteringColor(guid,target,radius,eps,thresh);
else
out=img.FilteringGray(guid,target,radius,eps,thresh);
}
else
{
if(strcmp(guidfile,dstfile)!=0)
{
cout<<"Warning: the guidance and the target should be the same image for iterative filtering.";
cout<<" Therefore, guidance image is neglected ..."<<endl;
}
out=img.IterFiltering(target,target,radius, eps,thresh,Iter);
}
imwrite(outfile,out);
return 0;
}