Instrument Neutral Distributed Interface INDI 2.2.5
feature.c
Go to the documentation of this file.
1/*
2* DSP API - a digital signal processing library for astronomy usage
3* Copyright © 2017-2021 Ilia Platone
4*
5* This program is free software; you can redistribute it and/or
6* modify it under the terms of the GNU Lesser General Public
7* License as published by the Free Software Foundation; either
8* version 3 of the License, or (at your option) any later version.
9*
10* This program is distributed in the hope that it will be useful,
11* but WITHOUT ANY WARRANTY; without even the implied warranty of
12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13* Lesser General Public License for more details.
14*
15* You should have received a copy of the GNU Lesser General Public License
16* along with this program; if not, write to the Free Software Foundation,
17* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18*/
19
20#include "dsp.h"
21
23{
24 int z;
25 dsp_fourier_dft(matrix, 1);
26 for(z = 0; z < matrix->sizes[stream->dims]; z++) {
27 dsp_fourier_dft(stream, 1);
28 int x, y, d;
29 dsp_t mn = dsp_stats_min(stream->buf, stream->len);
30 dsp_t mx = dsp_stats_max(stream->buf, stream->len);
31 int* d_pos = (int*)malloc(sizeof(int)*stream->dims);
32 for(y = z*stream->len; y < z*stream->len+stream->len; y++) {
33 int* pos = dsp_stream_get_position(matrix, y);
34 for(d = 0; d < stream->dims; d++) {
35 d_pos[d] = stream->sizes[d]/2+pos[d]-matrix->sizes[d]/2;
36 }
37 x = dsp_stream_set_position(stream, d_pos);
38 free(pos);
39 stream->magnitude->buf[x] *= sqrt(matrix->magnitude->buf[y]);
40 }
41 free(d_pos);
42 dsp_fourier_idft(stream);
43 dsp_buffer_stretch(stream->buf, stream->len, mn, mx);
44 }
45}
void dsp_feature_align(dsp_stream_p stream, dsp_stream_p matrix)
Definition feature.c:22
double dsp_t
Definition dsp.h:76
int * sizes
Sizes of each dimension.
Definition dsp.h:389
struct dsp_stream_t * magnitude
Fourier transform magnitude.
Definition dsp.h:427
int dims
Number of dimensions of the buffers.
Definition dsp.h:387
dsp_t * buf
buffer
Definition dsp.h:391
int len
The buffers length.
Definition dsp.h:385
#define dsp_buffer_stretch(buf, len, _mn, _mx)
Stretch minimum and maximum values of the input stream.
Definition dsp.h:808
DLL_EXPORT int dsp_stream_set_position(dsp_stream_p stream, int *pos)
Obtain the position the DSP stream by parsing multidimensional indexes.
Definition stream.c:471
DLL_EXPORT int * dsp_stream_get_position(dsp_stream_p stream, int index)
Return the multidimensional positional indexes of a DSP stream by specify a linear index.
Definition stream.c:451
DLL_EXPORT void dsp_fourier_idft(dsp_stream_p stream)
Perform an inverse discrete Fourier Transform of a dsp_stream.
Definition fft.c:173
DLL_EXPORT void dsp_fourier_dft(dsp_stream_p stream, int exp)
Perform a discrete Fourier Transform of a dsp_stream.
Definition fft.c:135
#define dsp_stats_min(buf, len)
Gets the minimum value of the input stream.
Definition dsp.h:578
#define dsp_stats_max(buf, len)
Gets the maximum value of the input stream.
Definition dsp.h:596
Contains a set of information and data relative to a buffer and how to use it.
Definition dsp.h:379