-
Notifications
You must be signed in to change notification settings - Fork 0
/
pupfft.c
86 lines (68 loc) · 2.07 KB
/
pupfft.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
/** @file pupfft.c
*/
#include "CommandLineInterface/CLIcore.h"
#include "COREMOD_memory/COREMOD_memory.h"
#include "dofft.h"
#include "permut.h"
/* inv = 0 for direct fft and 1 for inverse fft */
/* direct = focal plane -> pupil plane equ. fft2d(..,..,..,1) */
/* inverse = pupil plane -> focal plane equ. fft2d(..,..,..,0) */
/* options : -reim takes real/imaginary input and creates real/imaginary output
-inv for inverse fft (inv=1) */
errno_t pupfft(const char *ID_name_ampl,
const char *ID_name_pha,
const char *ID_name_ampl_out,
const char *ID_name_pha_out,
const char *options)
{
int reim;
int inv;
char Ctmpname[STRINGMAXLEN_IMGNAME];
char C1tmpname[STRINGMAXLEN_IMGNAME];
reim = 0;
inv = 0;
if(strstr(options, "-reim") != NULL)
{
/* printf("taking real / imaginary input/output\n");*/
reim = 1;
}
if(strstr(options, "-inv") != NULL)
{
/*printf("doing the inverse Fourier transform\n");*/
inv = 1;
}
WRITE_IMAGENAME(Ctmpname, "_Ctmp_%d", (int) getpid());
if(reim == 0)
{
mk_complex_from_amph(ID_name_ampl, ID_name_pha, Ctmpname, 0);
}
else
{
mk_complex_from_reim(ID_name_ampl, ID_name_pha, Ctmpname, 0);
}
permut(Ctmpname);
WRITE_IMAGENAME(C1tmpname, "_C1tmp_%d", (int) getpid());
if(inv == 0)
{
do2dfft(Ctmpname, C1tmpname); /* equ. fft2d(..,1) */
}
else
{
do2dffti(Ctmpname, C1tmpname); /* equ. fft2d(..,0) */
}
delete_image_ID(Ctmpname, DELETE_IMAGE_ERRMODE_WARNING);
if(reim == 0)
{
/* if this line is removed, the program crashes... why ??? */
/* list_image_ID(data); */
mk_amph_from_complex(C1tmpname, ID_name_ampl_out, ID_name_pha_out, 0);
}
else
{
mk_reim_from_complex(C1tmpname, ID_name_ampl_out, ID_name_pha_out, 0);
}
delete_image_ID(C1tmpname, DELETE_IMAGE_ERRMODE_WARNING);
permut(ID_name_ampl_out);
permut(ID_name_pha_out);
return RETURN_SUCCESS;
}