File: freq_dispatch.c

package info (click to toggle)
vips 8.4.5-1%2Bdeb9u1
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 25,724 kB
  • sloc: ansic: 102,605; cpp: 57,527; sh: 4,957; xml: 3,317; python: 3,105; makefile: 1,089; perl: 40
file content (335 lines) | stat: -rw-r--r-- 7,809 bytes parent folder | download | duplicates (2)
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
/* Function dispatch tables for freq_filt.
 *
 * J. Cupitt, 23/2/95
 * 22/4/97 JC
 *	- oops, im_freqflt() was wrong
 */

/*

    This file is part of VIPS.
    
    VIPS is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser 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 Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301  USA

 */

/*

    These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk

 */

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif /*HAVE_CONFIG_H*/
#include <vips/intl.h>

#include <stdio.h>
#include <stdarg.h>

#include <vips/vips.h>

/* One image in, one out.
 */
static im_arg_desc one_in_one_out[] = {
	IM_INPUT_IMAGE( "in" ),
	IM_OUTPUT_IMAGE( "out" )
};

/* Two images in, one out.
 */
static im_arg_desc two_in_one_out[] = {
	IM_INPUT_IMAGE( "in1" ),
	IM_INPUT_IMAGE( "in2" ),
	IM_OUTPUT_IMAGE( "out" )
};

/* Args to im_create_fmask().
 */
static im_arg_desc create_fmask_args[] = {
	IM_OUTPUT_IMAGE( "out" ),
	IM_INPUT_INT( "width" ),
	IM_INPUT_INT( "height" ),
	IM_INPUT_INT( "type" ),
	IM_INPUT_DOUBLE( "p1" ),
	IM_INPUT_DOUBLE( "p2" ),
	IM_INPUT_DOUBLE( "p3" ),
	IM_INPUT_DOUBLE( "p4" ),
	IM_INPUT_DOUBLE( "p5" )
};

/* Call im_create_fmask via arg vector.
 */
static int
create_fmask_vec( im_object *argv )
{
	int width = *((int *) argv[1]);
	int height = *((int *) argv[2]);
	int type = *((int *) argv[3]);
	double p1 = *((double *) argv[4]);
	double p2 = *((double *) argv[5]);
	double p3 = *((double *) argv[6]);
	double p4 = *((double *) argv[7]);
	double p5 = *((double *) argv[8]);

	return( im_create_fmask( argv[0], width, height,
		type, p1, p2, p3, p4, p5 ) );
}

/* Description of im_create_fmask.
 */ 
static im_function create_fmask_desc = {
	"im_create_fmask", 		/* Name */
	"create frequency domain filter mask",
	0,				/* Flags */
	create_fmask_vec, 		/* Dispatch function */
	IM_NUMBER( create_fmask_args ), 	/* Size of arg list */
	create_fmask_args 		/* Arg list */
};

/* Args to im_flt_image_freq().
 */
static im_arg_desc flt_image_freq_args[] = {
	IM_INPUT_IMAGE( "in" ),
	IM_OUTPUT_IMAGE( "out" ),
	IM_INPUT_INT( "type" ),
	IM_INPUT_DOUBLE( "p1" ),
	IM_INPUT_DOUBLE( "p2" ),
	IM_INPUT_DOUBLE( "p3" ),
	IM_INPUT_DOUBLE( "p4" ),
	IM_INPUT_DOUBLE( "p5" )
};

/* Call im_flt_image_freq via arg vector.
 */
static int
flt_image_freq_vec( im_object *argv )
{
	int type = *((int *) argv[2]);
	double p1 = *((double *) argv[3]);
	double p2 = *((double *) argv[4]);
	double p3 = *((double *) argv[5]);
	double p4 = *((double *) argv[6]);
	double p5 = *((double *) argv[7]);

	return( im_flt_image_freq( argv[0], argv[1], 
		type, p1, p2, p3, p4, p5 ) );
}

/* Description of im_flt_image_freq.
 */ 
static im_function flt_image_freq_desc = {
	"im_flt_image_freq", 		/* Name */
	"frequency domain filter image",
	0,				/* Flags */
	flt_image_freq_vec, 		/* Dispatch function */
	IM_NUMBER( flt_image_freq_args ), 	/* Size of arg list */
	flt_image_freq_args 		/* Arg list */
};

/* Args to im_fractsurf().
 */
static im_arg_desc fractsurf_args[] = {
	IM_OUTPUT_IMAGE( "out" ),
	IM_INPUT_INT( "size" ),
	IM_INPUT_DOUBLE( "dimension" )
};

/* Call im_fractsurf via arg vector.
 */
static int
fractsurf_vec( im_object *argv )
{
	int size = *((int *) argv[1]);
	double dim = *((double *) argv[2]);

	return( im_fractsurf( argv[0], size, dim ) );
}

/* Description of im_fractsurf.
 */ 
static im_function fractsurf_desc = {
	"im_fractsurf", 			/* Name */
	"generate a fractal surface of given dimension",
	IM_FN_TRANSFORM,		/* Flags */
	fractsurf_vec, 			/* Dispatch function */
	IM_NUMBER( fractsurf_args ), 	/* Size of arg list */
	fractsurf_args 			/* Arg list */
};

/* Args to im_freqflt().
 */
static im_arg_desc freqflt_args[] = {
	IM_INPUT_IMAGE( "in" ),
	IM_INPUT_IMAGE( "mask" ),
	IM_OUTPUT_IMAGE( "out" )
};

/* Call im_freqflt via arg vector.
 */
static int
freqflt_vec( im_object *argv )
{
	return( im_freqflt( argv[0], argv[1], argv[2] ) );
}

/* Description of im_freqflt.
 */ 
static im_function freqflt_desc = {
	"im_freqflt", 			/* Name */
	"frequency-domain filter of in with mask",
	IM_FN_TRANSFORM,		/* Flags */
	freqflt_vec, 			/* Dispatch function */
	IM_NUMBER( freqflt_args ), 	/* Size of arg list */
	freqflt_args 			/* Arg list */
};

/* Call im_disp_ps via arg vector.
 */
static int
disp_ps_vec( im_object *argv )
{
	return( im_disp_ps( argv[0], argv[1] ) );
}

/* Description of im_disp_ps.
 */ 
static im_function disp_ps_desc = {
	"im_disp_ps", 			/* Name */
	"make displayable power spectrum",
	IM_FN_TRANSFORM,		/* Flags */
	disp_ps_vec, 			/* Dispatch function */
	IM_NUMBER( one_in_one_out ), 	/* Size of arg list */
	one_in_one_out 			/* Arg list */
};

/* Call im_rotquad via arg vector.
 */
static int
rotquad_vec( im_object *argv )
{
	return( im_rotquad( argv[0], argv[1] ) );
}

/* Description of im_rotquad.
 */ 
static im_function rotquad_desc = {
	"im_rotquad", 			/* Name */
	"rotate image quadrants to move origin to centre",
	IM_FN_TRANSFORM,		/* Flags */
	rotquad_vec, 			/* Dispatch function */
	IM_NUMBER( one_in_one_out ), 	/* Size of arg list */
	one_in_one_out 			/* Arg list */
};

/* Call im_fwfft via arg vector.
 */
static int
fwfft_vec( im_object *argv )
{
	return( im_fwfft( argv[0], argv[1] ) );
}

/* Description of im_fwfft.
 */ 
static im_function fwfft_desc = {
	"im_fwfft", 			/* Name */
	"forward fast-fourier transform",
	IM_FN_TRANSFORM,		/* Flags */
	fwfft_vec, 			/* Dispatch function */
	IM_NUMBER( one_in_one_out ), 	/* Size of arg list */
	one_in_one_out 			/* Arg list */
};

/* Call im_invfft via arg vector.
 */
static int
invfft_vec( im_object *argv )
{
	return( im_invfft( argv[0], argv[1] ) );
}

/* Description of im_invfft.
 */ 
static im_function invfft_desc = {
	"im_invfft", 			/* Name */
	"inverse fast-fourier transform",
	IM_FN_TRANSFORM,		/* Flags */
	invfft_vec, 			/* Dispatch function */
	IM_NUMBER( one_in_one_out ), 	/* Size of arg list */
	one_in_one_out 			/* Arg list */
};

/* Call im_invfftr via arg vector.
 */
static int
invfftr_vec( im_object *argv )
{
	return( im_invfftr( argv[0], argv[1] ) );
}

/* Description of im_invfftr.
 */ 
static im_function invfftr_desc = {
	"im_invfftr", 			/* Name */
	"real part of inverse fast-fourier transform",
	IM_FN_TRANSFORM,		/* Flags */
	invfftr_vec, 			/* Dispatch function */
	IM_NUMBER( one_in_one_out ), 	/* Size of arg list */
	one_in_one_out 			/* Arg list */
};

/* Call im_phasecor_fft via arg vector.
 */
static int
phasecor_fft_vec( im_object *argv )
{
	return( im_phasecor_fft( argv[0], argv[1], argv[2] ) );
}

/* Description of im_phasecor_fft.
 */ 
static im_function phasecor_fft_desc = {
	"im_phasecor_fft",	 		/* Name */
	"non-normalised correlation of gradient of in2 within in1",
	IM_FN_TRANSFORM,	/* Flags */
	phasecor_fft_vec, 			/* Dispatch function */
	IM_NUMBER( two_in_one_out ), 	/* Size of arg list */
	two_in_one_out 			/* Arg list */
};

/* Package up all these functions.
 */
static im_function *freq_list[] = {
	&create_fmask_desc,
	&disp_ps_desc,
	&flt_image_freq_desc,
	&fractsurf_desc,
	&freqflt_desc,
	&fwfft_desc,
	&rotquad_desc,
	&invfft_desc,
	&phasecor_fft_desc,
	&invfftr_desc
};

/* Package of functions.
 */
im_package im__freq_filt = {
	"freq_filt",
	IM_NUMBER( freq_list ),
	freq_list
};