-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMtentwt.c
109 lines (83 loc) · 2.52 KB
/
Mtentwt.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
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/* Tent-like weight for patching.
*/
/*
Copyright (C) 2004 University of Texas at Austin
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <rsf.h>
#include "tent.h"
#include "mkwallwt.h"
int main(int argc, char* argv[])
{
int dim, i, j, *n, *w, *k, *a, *center, n12, w12;
float *wind, *wall;
char string[256];
bool tnt;
sf_file wallwt, windwt;
sf_init (argc, argv);
wallwt = sf_output("out");
windwt = sf_output("windwt");
sf_setformat(wallwt,"native_float");
sf_setformat(windwt,"native_float");
if (!sf_getint ("dim",&dim)) dim = 2;
/* number of dimensions */
n = sf_intalloc (dim);
w = sf_intalloc (dim);
k = sf_intalloc (dim);
center = sf_intalloc (dim);
a = sf_intalloc (dim);
n12 = 1;
for(j=0; j < dim; j++) {
sprintf(string,"n%d",j+1);
if (!sf_getint(string,&n[j])) n[j]=1;
sf_putint(wallwt,string,n[j]);
n12 *= n[j];
}
if (!sf_getints ("w",w,dim)) sf_error("Need w=");
/* window size */
w12 = 1;
for(j=0; j < dim; j++) {
if (w[j] > n[j]) w[j] = n[j];
k[j] = 1.5 * n[j] / (w[j] - a[j] + 1.);
a[j] = 1;
center[j] = 1;
w12 *= w[j];
sprintf(string,"n%d",j+1);
sf_putint(windwt,string,w[j]);
}
sf_getints ("k",k,dim);
/* number of windows */
sf_getints ("a",a,dim);
/* filter size */
for(j=1; j < dim; j++) {
if (a[j] > 1) center[j-1] = a[j-1]/2;
}
sf_getints ("center",center,dim);
if (!sf_getbool ("tent",&tnt)) tnt = true;
/* if y, use tent-like weight; n, cosine weight */
wall = sf_floatalloc(n12);
wind = sf_floatalloc(w12);
if (tnt) {
tent (dim, w, center, a, wind);
} else {
sf_tent2 (dim, w, wind);
}
sf_floatwrite (wind, w12, windwt);
mkwallwt (dim, k, n, w, wind, wall);
for (i=0; i < n12; i++) {
if (wall[i] != 0.) wall[i] = 1. / wall[i];
}
sf_floatwrite (wall, n12, wallwt);
exit (0);
}
/* $Id$ */