Open source Very Long Baseline Interferometry
OpenVLBI
dsp.h
1/* libDSP - a digital signal processing library
2 * Copyright © 2017-2022 Ilia Platone
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 3 of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18
19#ifndef _DSP_H
20#define _DSP_H
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26#ifndef DLL_EXPORT
27#define DLL_EXPORT extern
28#endif
29
30#ifdef __linux__
31#include <endian.h>
32#else
33#define __bswap_16(a) __builtin_bswap16(a)
34#define __bswap_32(a) __builtin_bswap32(a)
35#define __bswap_64(a) __builtin_bswap64(a)
36#endif
37#include <stdio.h>
38#include <stdlib.h>
39#include <string.h>
40#include <math.h>
41#include <float.h>
42#include <sys/types.h>
43#include <time.h>
44#include <assert.h>
45#include <pthread.h>
46#include <time.h>
47
68#define DSP_MAX_STARS 200
69typedef double dsp_t;
70typedef double complex_t[2];
71#define dsp_t_max 255
72#define dsp_t_min -dsp_t_max
73
79DLL_EXPORT unsigned long int dsp_max_threads(unsigned long value);
80
81#ifndef DSP_DEBUG
82#define DSP_DEBUG
87DLL_EXPORT void dsp_set_debug_level(int value);
92DLL_EXPORT int dsp_get_debug_level();
97DLL_EXPORT void dsp_set_app_name(char* name);
102DLL_EXPORT char* dsp_get_app_name();
107DLL_EXPORT void dsp_set_stdout(FILE *f);
112DLL_EXPORT void dsp_set_stderr(FILE *f);
113
119DLL_EXPORT void dsp_print(int x, char* str);
120
121#define DSP_DEBUG_INFO 0
122#define DSP_DEBUG_ERROR 1
123#define DSP_DEBUG_WARNING 2
124#define DSP_DEBUG_DEBUG 3
125#define pdbg(x, ...) ({ \
126char str[500]; \
127struct timespec ts; \
128time_t t = time(NULL); \
129struct tm tm = *localtime(&t); \
130clock_gettime(CLOCK_REALTIME, &ts); \
131sprintf(str, "[%04d-%02d-%02dT%02d:%02d:%02d.%03ld ", tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, ts.tv_nsec/1000000); \
132switch(x) { \
133 case DSP_DEBUG_ERROR: \
134 sprintf(&str[strlen(str)], "ERRO]"); \
135 break; \
136 case DSP_DEBUG_WARNING: \
137 sprintf(&str[strlen(str)], "WARN]"); \
138 break; \
139 case DSP_DEBUG_DEBUG: \
140 sprintf(&str[strlen(str)], "DEBG]"); \
141 break; \
142 default: \
143 sprintf(&str[strlen(str)], "INFO]"); \
144 break; \
145} \
146if(dsp_get_app_name() != NULL) \
147 sprintf(&str[strlen(str)], "[%s]", dsp_get_app_name()); \
148sprintf(&str[strlen(str)], " "); \
149sprintf(&str[strlen(str)], __VA_ARGS__); \
150dsp_print(x, str); \
151})
152#define pinfo(...) pdbg(DSP_DEBUG_INFO, __VA_ARGS__)
153#define perr(...) pdbg(DSP_DEBUG_ERROR, __VA_ARGS__)
154#define pwarn(...) pdbg(DSP_DEBUG_WARNING, __VA_ARGS__)
155#define pgarb(...) pdbg(DSP_DEBUG_DEBUG, __VA_ARGS__)
156#define pfunc pgarb("%s\n", __func__)
157#define start_gettime
158#define end_gettime
159#else
160#define pinfo(...)
161#define perr(...)
162#define pwarn(...)
163#define pgarb(...)
164#define pfunc(...)
165#define start_gettime(...)
166#define end_gettime(...)
167#endif
168
169
171#ifndef Min
172#define Min(a,b) \
173 ({ __typeof (a) _a = (a); \
174 __typeof (a) _b = (b); \
175 _a < _b ? _a : _b; })
176#endif
178#ifndef Max
179#define Max(a,b) \
180 ({ __typeof (a) _a = (a); \
181 __typeof (a) _b = (b); \
182 _a > _b ? _a : _b; })
183#endif
185#ifndef Log
186#define Log(a,b) \
187( log(a) / log(b) )
188#endif
189#ifndef DSP_ALIGN_TRANSLATED
191#define DSP_ALIGN_TRANSLATED 1
192#endif
193#ifndef DSP_ALIGN_SCALED
195#define DSP_ALIGN_SCALED 2
196#endif
197#ifndef DSP_ALIGN_ROTATED
199#define DSP_ALIGN_ROTATED 4
200#endif
201#ifndef DSP_ALIGN_NO_MATCH
203#define DSP_ALIGN_NO_MATCH 8
204#endif
215typedef struct dsp_point_t
216{
218 double* location;
220 int dims;
222
226typedef struct dsp_offset_t
227{
229 double* offset;
231 int dims;
233
237typedef struct dsp_star_t
238{
242 double diameter;
244 char name[150];
246
250typedef struct dsp_triangle_t
251{
253 double index;
255 int dims;
257 double *theta;
259 double *sizes;
261 double *ratios;
265
269typedef struct dsp_align_info_t
270{
272 double* offset;
274 double* center;
276 double* radians;
278 double* factor;
280 int dims;
286 double score;
288 double decimals;
290 int err;
292
297typedef union
298{
300 struct
301 {
303 double real;
305 double imaginary;
306 } *complex;
308 complex_t *pairs;
310 double *buf;
312
316typedef struct dsp_region_t
317{
319 int start;
321 int len;
323
327typedef union dsp_location_t
328{
330 struct
331 {
332 double x;
333 double y;
334 double z;
337 struct
338 {
339 double lon;
340 double lat;
341 double el;
344 double coordinates[3];
346
350typedef void *(*dsp_func_t) (void *, ...);
351
362typedef struct dsp_stream_t
363{
365 char name[128];
369 int len;
371 int dims;
373 int* sizes;
375 dsp_t* buf;
379 void *arg;
389 double* target;
391 struct timespec starttimeutc;
397 double diameter;
399 double SNR;
401 int red;
403 double *pixel_sizes;
407 pthread_t thread;
429
441DLL_EXPORT void dsp_fourier_dft(dsp_stream_p stream, int exp);
442
447DLL_EXPORT void dsp_fourier_idft(dsp_stream_p stream);
448
453DLL_EXPORT void dsp_fourier_2dsp(dsp_stream_p stream);
454
459DLL_EXPORT void dsp_fourier_2complex_t(dsp_stream_p stream);
460
469DLL_EXPORT void dsp_fourier_phase_mag_array_get_complex(double* mag, double* phi, complex_t *out, int len);
470
478
486
496DLL_EXPORT void dsp_filter_squarelaw(dsp_stream_p stream);
497
503DLL_EXPORT void dsp_filter_lowpass(dsp_stream_p stream, double frequency);
504
510DLL_EXPORT void dsp_filter_highpass(dsp_stream_p stream, double frequency);
511
518DLL_EXPORT void dsp_filter_bandpass(dsp_stream_p stream, double LowFrequency,
519 double HighFrequency);
520
527DLL_EXPORT void dsp_filter_bandreject(dsp_stream_p stream, double LowFrequency,
528 double HighFrequency);
529
541
548
555#ifndef dsp_stats_min
562#define dsp_stats_min(buf, len)\
563({\
564 int i;\
565 __typeof(buf[0]) min = (__typeof(buf[0]))buf[0];\
566 for(i = 0; i < len; i++) {\
567 min = Min(buf[i], min);\
568 }\
569 min;\
570 })
571#endif
572
573#ifndef dsp_stats_max
580#define dsp_stats_max(buf, len)\
581({\
582 int i;\
583 __typeof(buf[0]) max = (__typeof(buf[0]))buf[0];\
584 for(i = 0; i < len; i++) {\
585 max = Max(buf[i], max);\
586 }\
587 max;\
588 })
589#endif
590
591#ifndef dsp_stats_mid
598#define dsp_stats_mid(buf, len)\
599({\
600 int i;\
601 __typeof(buf[0]) min = dsp_stats_min(buf, len);\
602 (__typeof(buf[0]))(min - dsp_stats_max(buf, len)) / 2.0 + min;\
603})
604#endif
605
606#ifndef dsp_stats_maximum_index
613#define dsp_stats_minimum_index(buf, len)\
614({\
615 int i;\
616 __typeof(buf[0]) min = dsp_stats_min(buf, len);\
617 for(i = 0; i < len; i++) {\
618 if(buf[i] == min) break;\
619 }\
620 i;\
621 })
622#endif
623
624#ifndef dsp_stats_maximum_index
631#define dsp_stats_maximum_index(buf, len)\
632({\
633 int i;\
634 __typeof(buf[0]) max = dsp_stats_max(buf, len);\
635 for(i = 0; i < len; i++) {\
636 if(buf[i] == max) break;\
637 }\
638 i;\
639 })
640#endif
641
642#ifndef dsp_stats_stddev
649#define dsp_stats_mean(buf, len)\
650({\
651 int __dsp__i;\
652 double __dsp__mean = 0;\
653 for(__dsp__i = 0; __dsp__i < len; __dsp__i++) {\
654 __dsp__mean += buf[__dsp__i];\
655 }\
656 __dsp__mean /= len;\
657 __dsp__mean;\
658 })
659#endif
660
661#ifndef dsp_stats_stddev
667#define dsp_stats_stddev(buf, len)\
668({\
669 double __dsp__mean = dsp_stats_mean(buf, len);\
670 int __dsp__x;\
671 double __dsp__stddev = 0;\
672 for(__dsp__x = 0; __dsp__x < len; __dsp__x++) {\
673 __dsp__stddev += fabs(buf[__dsp__x] - __dsp__mean);\
674 }\
675 __dsp__stddev /= len;\
676 __dsp__stddev;\
677 })
678#endif
679
680#ifndef dsp_stats_val_count
688#define dsp_stats_val_count(buf, len, val) \
689({\
690 int x;\
691 int count = 0;\
692 for(x = 0; x < len; x++) {\
693 if(buf[x] == val)\
694 count ++;\
695 }\
696 count;\
697 })
698#endif
699
700#ifndef dsp_stats_val_sum
707#define dsp_stats_val_sum(buf, len) \
708({\
709 int x;\
710 double sum = 0;\
711 for(x = 0; x < len; x++) {\
712 sum += buf[x];\
713 }\
714 sum;\
715 })
716#endif
717
718#ifndef dsp_stats_range_count
727#define dsp_stats_range_count(buf, len, lo, hi) \
728({\
729 int x;\
730 int count = 0;\
731 for(x = 0; x < len; x++) {\
732 if(buf[x] < hi && buf[x] >= lo)\
733 count ++;\
734 }\
735 count;\
736 })
737#endif
738
739#ifndef dsp_stats_compare
747#define dsp_stats_compare(in1, in2, len)\
748({\
749 __typeof(in1[0]) out = 0;\
750 for(int i = 0; i < len; i++) {\
751 out += in1[i] - (__typeof(in1[0]))in2[i];\
752 }\
753 out;\
754 })
755#endif
756
764DLL_EXPORT double* dsp_stats_histogram(dsp_stream_p stream, int size);
765
776DLL_EXPORT void dsp_buffer_shift(dsp_stream_p stream);
777
782DLL_EXPORT void dsp_buffer_removemean(dsp_stream_p stream);
783
784#ifndef dsp_buffer_stretch
792#define dsp_buffer_stretch(buf, len, _mn, _mx)\
793({\
794 int k;\
795 __typeof(buf[0]) __mn = dsp_stats_min(buf, len);\
796 __typeof(buf[0]) __mx = dsp_stats_max(buf, len);\
797 double oratio = (_mx - _mn);\
798 double iratio = (__mx - __mn);\
799 if(iratio == 0) iratio = 1;\
800 for(k = 0; k < len; k++) {\
801 buf[k] -= __mn;\
802 buf[k] = (__typeof(buf[0]))((double)buf[k] * oratio / iratio);\
803 buf[k] += _mn;\
804 }\
805})
806#endif
807
808#ifndef dsp_buffer_set
815#define dsp_buffer_set(buf, len, _val)\
816({\
817 int k;\
818 for(k = 0; k < len; k++) {\
819 buf[k] = (__typeof(buf[0]))(_val);\
820 }\
821})
822#endif
823
824#ifndef dsp_buffer_normalize
832#define dsp_buffer_normalize(buf, len, mn, mx)\
833({\
834 int k;\
835 for(k = 0; k < len; k++) {\
836 buf[k] = Max(mn, Min(mx, buf[k]));\
837 }\
838})
839#endif
840
847DLL_EXPORT void dsp_buffer_max(dsp_stream_p stream, dsp_t* in, int len);
848
855DLL_EXPORT void dsp_buffer_min(dsp_stream_p stream, dsp_t* in, int len);
856
863DLL_EXPORT void dsp_buffer_sub(dsp_stream_p stream, dsp_t* in, int len);
864
871DLL_EXPORT void dsp_buffer_sum(dsp_stream_p stream, dsp_t* in, int len);
872
879DLL_EXPORT void dsp_buffer_div(dsp_stream_p stream, dsp_t* in, int len);
880
887DLL_EXPORT void dsp_buffer_mul(dsp_stream_p stream, dsp_t* in, int len);
888
895DLL_EXPORT void dsp_buffer_pow(dsp_stream_p stream, dsp_t* in, int len);
896
903DLL_EXPORT void dsp_buffer_log(dsp_stream_p stream, dsp_t* in, int len);
904
910DLL_EXPORT void dsp_buffer_sub1(dsp_stream_p stream, dsp_t val);
911
917DLL_EXPORT void dsp_buffer_1sub(dsp_stream_p stream, dsp_t val);
918
924DLL_EXPORT void dsp_buffer_sum1(dsp_stream_p stream, dsp_t val);
925
931DLL_EXPORT void dsp_buffer_div1(dsp_stream_p stream, double val);
932
938DLL_EXPORT void dsp_buffer_1div(dsp_stream_p stream, double val);
939
945DLL_EXPORT void dsp_buffer_mul1(dsp_stream_p stream, double val);
946
952DLL_EXPORT void dsp_buffer_pow1(dsp_stream_p stream, double val);
953
959DLL_EXPORT void dsp_buffer_log1(dsp_stream_p stream, double val);
960
967DLL_EXPORT void dsp_buffer_median(dsp_stream_p stream, int size, int median);
968
974DLL_EXPORT void dsp_buffer_sigma(dsp_stream_p stream, int size);
975
983DLL_EXPORT void dsp_buffer_deviate(dsp_stream_p stream, dsp_t* deviation, dsp_t mindeviation, dsp_t maxdeviation);
984
985#ifndef dsp_buffer_reverse
991#define dsp_buffer_reverse(buf, len) \
992 ({ \
993 int i = (len - 1) / 2; \
994 int j = i + 1; \
995 __typeof(buf[0]) _x; \
996 while(i >= 0) \
997 { \
998 _x = buf[j]; \
999 buf[j] = buf[i]; \
1000 buf[i] = _x; \
1001 i--; \
1002 j++; \
1003 } \
1004 })
1005#endif
1006
1007#ifndef dsp_buffer_swap
1013#define dsp_buffer_swap(in, len) \
1014 ({ \
1015 int k; \
1016 switch(sizeof(((__typeof (in[0])*)in)[0])) { \
1017 case 2: \
1018 for(k = 0; k < len; k++) \
1019 ((__typeof (in[0])*)in)[k] = __bswap_16(((__typeof (in[0])*)in)[k]); \
1020 break; \
1021 case 3: \
1022 for(k = 0; k < len; k++) \
1023 ((__typeof (in[0])*)in)[k] = __bswap_32(((__typeof (in[0])*)in)[k]); \
1024 break; \
1025 } \
1026 })
1027#endif
1028
1029#ifndef dsp_buffer_copy
1038#define dsp_buffer_copy(in, out, len) \
1039 ({ \
1040 int k; \
1041 for(k = 0; k < len; k++) { \
1042 ((__typeof (out[0])*)out)[k] = (__typeof (out[0]))((__typeof (in[0])*)in)[k]; \
1043 } \
1044 })
1045#endif
1046
1047#ifndef dsp_buffer_copy_stepping
1059#define dsp_buffer_copy_stepping(in, out, inlen, outlen, instep, outstep) \
1060 ({ \
1061 int k; \
1062 int t; \
1063 for(k = 0, t = 0; k < inlen && t < outlen; k+=instep, t+=outstep) { \
1064 ((__typeof (out[0])*)out)[t] = (__typeof (out[0]))((__typeof (in[0])*)in)[k]; \
1065 } \
1066 })
1067#endif
1068
1080DLL_EXPORT void dsp_stream_alloc_buffer(dsp_stream_p stream, int len);
1081
1088DLL_EXPORT void dsp_stream_set_buffer(dsp_stream_p stream, void *buffer, int len);
1089
1095DLL_EXPORT dsp_t* dsp_stream_get_buffer(dsp_stream_p stream);
1096
1101DLL_EXPORT void dsp_stream_free_buffer(dsp_stream_p stream);
1102
1109
1115DLL_EXPORT void dsp_stream_free(dsp_stream_p stream);
1116
1124
1132DLL_EXPORT void dsp_stream_add_child(dsp_stream_p stream, dsp_stream_p child);
1133
1141DLL_EXPORT void dsp_stream_add_star(dsp_stream_p stream, dsp_star star);
1142
1150DLL_EXPORT void dsp_stream_del_star(dsp_stream_p stream, int n);
1151
1159DLL_EXPORT void dsp_stream_add_triangle(dsp_stream_p stream, dsp_triangle triangle);
1160
1168DLL_EXPORT void dsp_stream_del_triangle(dsp_stream_p stream, int index);
1169
1177
1185DLL_EXPORT void dsp_stream_del_child(dsp_stream_p stream, int n);
1186
1194DLL_EXPORT void dsp_stream_add_dim(dsp_stream_p stream, int len);
1195
1204DLL_EXPORT void dsp_stream_set_dim(dsp_stream_p stream, int dim, int size);
1205
1213DLL_EXPORT void dsp_stream_del_dim(dsp_stream_p stream, int n);
1214
1225DLL_EXPORT int dsp_stream_set_position(dsp_stream_p stream, int *pos);
1226
1237DLL_EXPORT int* dsp_stream_get_position(dsp_stream_p stream, int index);
1238
1248DLL_EXPORT void *dsp_stream_exec(dsp_stream_p stream, void *args, ...);
1249
1254DLL_EXPORT void dsp_stream_crop(dsp_stream_p stream);
1255
1260DLL_EXPORT void dsp_stream_rotate(dsp_stream_p stream);
1261
1266DLL_EXPORT void dsp_stream_translate(dsp_stream_p stream);
1267
1272DLL_EXPORT void dsp_stream_scale(dsp_stream_p stream);
1273
1278DLL_EXPORT void dsp_stream_align(dsp_stream_p stream);
1279
1290DLL_EXPORT void dsp_signals_whitenoise(dsp_stream_p stream);
1291
1298DLL_EXPORT void dsp_signals_sinewave(dsp_stream_p stream, double samplefreq, double freq);
1299
1306DLL_EXPORT void dsp_signals_sawtoothwave(dsp_stream_p stream, double samplefreq, double freq);
1307
1314DLL_EXPORT void dsp_signals_triwave(dsp_stream_p stream, double samplefreq, double freq);
1315
1323DLL_EXPORT void dsp_modulation_frequency(dsp_stream_p stream, double samplefreq, double freq, double bandwidth);
1324
1331DLL_EXPORT void dsp_modulation_amplitude(dsp_stream_p stream, double samplefreq, double freq);
1332
1346DLL_EXPORT dsp_stream_p* dsp_file_read_fits(const char* filename, int *channels, int stretch);
1347
1354DLL_EXPORT void dsp_file_write_fits(const char* filename, int bpp, dsp_stream_p stream);
1355
1363DLL_EXPORT void dsp_file_write_fits_composite(const char* filename, int components, int bpp, dsp_stream_p* stream);
1364
1373DLL_EXPORT dsp_stream_p* dsp_file_read_jpeg(const char* filename, int *channels, int stretch);
1374
1381DLL_EXPORT void dsp_file_write_jpeg(const char* filename, int quality, dsp_stream_p stream);
1382
1390DLL_EXPORT void dsp_file_write_jpeg_composite(const char* filename, int components, int quality, dsp_stream_p* stream);
1391
1400DLL_EXPORT dsp_stream_p* dsp_file_read_png(const char* filename, int *channels, int stretch);
1401
1409DLL_EXPORT void dsp_file_write_png_composite(const char* filename, int components, int compression, dsp_stream_p* stream);
1410
1418DLL_EXPORT dsp_t* dsp_file_bayer_2_gray(dsp_t* src, int width, int height);
1419
1428DLL_EXPORT dsp_t* dsp_file_bayer_2_rgb(dsp_t *src, int red, int width, int height);
1429
1438DLL_EXPORT dsp_stream_p *dsp_stream_from_components(dsp_t* buf, int dims, int *sizes, int components);
1439
1450DLL_EXPORT dsp_stream_p *dsp_buffer_rgb_to_components(void* buf, int dims, int *sizes, int components, int bpp, int stretch);
1451
1459DLL_EXPORT void dsp_buffer_components_to_rgb(dsp_stream_p *stream, void* rgb, int components, int bpp);
1460
1469DLL_EXPORT dsp_t* dsp_file_composite_2_bayer(dsp_stream_p *src, int red, int width, int height);
1470
1478DLL_EXPORT void dsp_file_write_fits_bayer(const char* filename, int components, int bpp, dsp_stream_p* stream);
1479
1488DLL_EXPORT dsp_t* dsp_file_bayer_2_composite(dsp_t *src, int red, int width, int height);
1489
1497
1504
1513DLL_EXPORT int dsp_align_get_offset(dsp_stream_p ref, dsp_stream_p to_align, double tolerance, double target_score);
1514
1517#include <fits_extensions.h>
1518
1519#ifdef __cplusplus
1520}
1521#endif
1522
1523#endif //_DSP_H
DLL_EXPORT int dsp_get_debug_level()
get the debug level
DLL_EXPORT void dsp_set_stderr(FILE *f)
set the error log streeam
DLL_EXPORT char * dsp_get_app_name()
get the application name
DLL_EXPORT unsigned long int dsp_max_threads(unsigned long value)
get/set the maximum number of threads allowed
DLL_EXPORT void dsp_set_debug_level(int value)
set the debug level
DLL_EXPORT void dsp_set_stdout(FILE *f)
set the output log streeam
DLL_EXPORT void dsp_print(int x, char *str)
log a message to the error or output streams
DLL_EXPORT void dsp_set_app_name(char *name)
set the application name
void *(* dsp_func_t)(void *,...)
Multi-dimensional processing delegate function.
Definition: dsp.h:350
struct dsp_region_t dsp_region
Delimits a region in a single dimension of a buffer.
struct dsp_offset_t dsp_offset
Indicates an offset.
struct dsp_point_t dsp_point
Indicates a dot or line inside a dsp_stream.
struct dsp_triangle_t dsp_triangle
A star or object contained into a buffer.
struct dsp_align_info_t dsp_align_info
Alignment informations needed.
struct dsp_stream_t dsp_stream
Contains a set of informations and data relative to a buffer and how to use it.
union dsp_location_t dsp_location
The location type.
struct dsp_star_t dsp_star
A star or object contained into a buffer.
struct dsp_stream_t * phase
Fourier transform phase.
Definition: dsp.h:413
double samplerate
Sample rate of the buffers.
Definition: dsp.h:405
void * arg
Optional argument for the func() callback.
Definition: dsp.h:379
char name[128]
Friendly name of the stream.
Definition: dsp.h:365
struct dsp_location_t::@1 xyz
The location in xyz coordinates.
double imaginary
Imaginary part of the complex number.
Definition: dsp.h:305
int err
Errors.
Definition: dsp.h:290
double * pixel_sizes
Sensor size.
Definition: dsp.h:403
dsp_point center
The center of the star.
Definition: dsp.h:240
int frame_number
Frame number (if part of a series)
Definition: dsp.h:427
int triangles_count
Triangles of stars or objects quantity.
Definition: dsp.h:423
int dims
Dimensions limit.
Definition: dsp.h:280
double * factor
Scaling factor.
Definition: dsp.h:278
double decimals
Decimals.
Definition: dsp.h:288
double wavelength
Wavelength observed, used as reference with signal generators or filters.
Definition: dsp.h:393
double focal_ratio
Focal ratio.
Definition: dsp.h:395
int start
Starting point within the buffer.
Definition: dsp.h:319
double * center
Center of rotation coordinates.
Definition: dsp.h:274
struct dsp_stream_t * parent
The parent stream.
Definition: dsp.h:381
int * sizes
Sizes of each dimension.
Definition: dsp.h:373
double * location
Center of the point.
Definition: dsp.h:218
dsp_complex dft
Fourier transform.
Definition: dsp.h:377
int red
Red pixel (Bayer)
Definition: dsp.h:401
double * radians
Rotational offset.
Definition: dsp.h:276
double index
The index of the triangle.
Definition: dsp.h:253
dsp_star * stars
Stars or objects identified into the buffers - TODO.
Definition: dsp.h:417
struct timespec starttimeutc
Time at the beginning of the stream.
Definition: dsp.h:391
dsp_star * stars
The stars of the triangle.
Definition: dsp.h:263
double * sizes
The sizes of the triangle.
Definition: dsp.h:259
double * buf
Linear double array containing complex numbers.
Definition: dsp.h:310
double * target
Target coordinates.
Definition: dsp.h:389
struct dsp_location_t::@2 geographic
The location in geographic coordinates.
int stars_count
Stars or objects quantity.
Definition: dsp.h:419
struct dsp_stream_t * magnitude
Fourier transform magnitude.
Definition: dsp.h:411
double diameter
The diameter of the star.
Definition: dsp.h:242
int dims
The dimensions of the triangle.
Definition: dsp.h:255
double coordinates[3]
A 3d double array containing the location.
Definition: dsp.h:344
double * theta
The inclination of the triangle.
Definition: dsp.h:257
double diameter
Diameter.
Definition: dsp.h:397
dsp_align_info align_info
Align/scale/rotation settings.
Definition: dsp.h:425
dsp_triangle * triangles
Triangles of stars or objects.
Definition: dsp.h:421
dsp_func_t func
Callback function.
Definition: dsp.h:409
int dims
Dimensions limit of the point.
Definition: dsp.h:231
char name[150]
The name of the star.
Definition: dsp.h:244
int dims
Number of dimensions of the buffers.
Definition: dsp.h:371
dsp_location * location
Location coordinates pointer, can be extended to the main buffer size as location companion.
Definition: dsp.h:387
double * offset
Center of the point.
Definition: dsp.h:229
struct dsp_stream_t ** children
Children streams.
Definition: dsp.h:383
dsp_t * buf
buffer
Definition: dsp.h:375
int len
Length of the region.
Definition: dsp.h:321
int triangles_count
Triangles quantity.
Definition: dsp.h:284
double SNR
SNR.
Definition: dsp.h:399
int dims
Dimensions limit of the point.
Definition: dsp.h:220
int child_count
Children streams count.
Definition: dsp.h:385
double score
Match score.
Definition: dsp.h:286
int is_copy
Increments by one on the copied stream.
Definition: dsp.h:367
double * ratios
The sizes of the triangle.
Definition: dsp.h:261
dsp_triangle triangles[2]
Reference triangles.
Definition: dsp.h:282
dsp_region * ROI
Regions of interest for each dimension.
Definition: dsp.h:415
int len
The buffers length.
Definition: dsp.h:369
pthread_t thread
Thread type for future usage.
Definition: dsp.h:407
double real
Real part of the complex number.
Definition: dsp.h:303
double * offset
Translation offset.
Definition: dsp.h:272
DLL_EXPORT void dsp_buffer_sum(dsp_stream_p stream, dsp_t *in, int len)
Sum elements of one stream to another's.
DLL_EXPORT void dsp_buffer_log(dsp_stream_p stream, dsp_t *in, int len)
Logarithm elements of one stream using another's as base.
DLL_EXPORT void dsp_buffer_median(dsp_stream_p stream, int size, int median)
Median elements of the input stream.
DLL_EXPORT void dsp_buffer_shift(dsp_stream_p stream)
Shift a stream on each dimension.
DLL_EXPORT void dsp_buffer_deviate(dsp_stream_p stream, dsp_t *deviation, dsp_t mindeviation, dsp_t maxdeviation)
Deviate forward the first input stream using the second stream as indexing reference.
DLL_EXPORT void dsp_buffer_div1(dsp_stream_p stream, double val)
Divide elements of the input stream to a value.
DLL_EXPORT void dsp_buffer_removemean(dsp_stream_p stream)
Subtract mean from stream.
DLL_EXPORT void dsp_buffer_1sub(dsp_stream_p stream, dsp_t val)
Subtract each element of the input stream a value.
DLL_EXPORT void dsp_buffer_max(dsp_stream_p stream, dsp_t *in, int len)
Subtract elements of one stream from another's.
DLL_EXPORT void dsp_buffer_sigma(dsp_stream_p stream, int size)
Standard deviation of each element of the input stream within the given size.
DLL_EXPORT void dsp_buffer_div(dsp_stream_p stream, dsp_t *in, int len)
Divide elements of one stream to another's.
DLL_EXPORT void dsp_buffer_sum1(dsp_stream_p stream, dsp_t val)
Sum elements of the input stream to a value.
DLL_EXPORT void dsp_buffer_mul(dsp_stream_p stream, dsp_t *in, int len)
Multiply elements of one stream to another's.
DLL_EXPORT void dsp_buffer_pow1(dsp_stream_p stream, double val)
Expose elements of the input stream to the given power.
DLL_EXPORT void dsp_buffer_log1(dsp_stream_p stream, double val)
Logarithm elements of the input stream using the given base.
DLL_EXPORT void dsp_buffer_pow(dsp_stream_p stream, dsp_t *in, int len)
Expose elements of one stream to another's.
DLL_EXPORT void dsp_buffer_min(dsp_stream_p stream, dsp_t *in, int len)
Sum elements of one stream to another's.
DLL_EXPORT void dsp_buffer_1div(dsp_stream_p stream, double val)
Divide a value to each element of the input stream.
DLL_EXPORT void dsp_buffer_sub(dsp_stream_p stream, dsp_t *in, int len)
Subtract elements of one stream from another's.
DLL_EXPORT void dsp_buffer_sub1(dsp_stream_p stream, dsp_t val)
Subtract a value from elements of the input stream.
DLL_EXPORT void dsp_buffer_mul1(dsp_stream_p stream, double val)
Multiply elements of the input stream to a value.
DLL_EXPORT void dsp_convolution_correlation(dsp_stream_p stream, dsp_stream_p matrix)
A cross-correlation processor.
DLL_EXPORT void dsp_convolution_convolution(dsp_stream_p stream, dsp_stream_p matrix)
A cross-convolution processor.
DLL_EXPORT void dsp_stream_free(dsp_stream_p stream)
Free the DSP stream passed as argument.
DLL_EXPORT void dsp_stream_scale(dsp_stream_p stream)
Scale a stream.
DLL_EXPORT void dsp_stream_set_dim(dsp_stream_p stream, int dim, int size)
Set a dimension size to a DSP stream.
DLL_EXPORT void dsp_stream_rotate(dsp_stream_p stream)
Rotate a stream around an axis and offset.
DLL_EXPORT void dsp_stream_del_triangle(dsp_stream_p stream, int index)
Remove the triangle with index n to a DSP stream.
DLL_EXPORT int dsp_stream_set_position(dsp_stream_p stream, int *pos)
Obtain the position the DSP stream by parsing multidimensional indexes.
DLL_EXPORT dsp_stream_p dsp_stream_copy(dsp_stream_p stream)
Create a copy of the DSP stream passed as argument.
DLL_EXPORT void dsp_stream_add_triangle(dsp_stream_p stream, dsp_triangle triangle)
Add a triangle to the DSP Stream passed as argument.
DLL_EXPORT void dsp_stream_add_child(dsp_stream_p stream, dsp_stream_p child)
Add a child to the DSP Stream passed as argument.
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.
DLL_EXPORT void dsp_stream_del_dim(dsp_stream_p stream, int n)
Remove the dimension with index n to a DSP stream.
DLL_EXPORT void dsp_stream_set_buffer(dsp_stream_p stream, void *buffer, int len)
Set the buffer of the stream passed as argument to a specific memory location.
DLL_EXPORT void dsp_stream_del_child(dsp_stream_p stream, int n)
Remove the child with index n to a DSP stream.
DLL_EXPORT dsp_stream_p dsp_stream_new(void)
Allocate a new DSP stream type.
DLL_EXPORT void dsp_stream_add_dim(dsp_stream_p stream, int len)
Add a dimension with length len to a DSP stream.
DLL_EXPORT void dsp_stream_alloc_buffer(dsp_stream_p stream, int len)
Allocate a buffer with length len on the stream passed as argument.
DLL_EXPORT void dsp_stream_crop(dsp_stream_p stream)
Crop the buffers of the stream passed as argument by reading the ROI field.
DLL_EXPORT void dsp_stream_translate(dsp_stream_p stream)
Translate a stream.
DLL_EXPORT void dsp_stream_free_buffer(dsp_stream_p stream)
Free the buffer of the DSP Stream passed as argument.
DLL_EXPORT void dsp_stream_del_star(dsp_stream_p stream, int n)
Remove the star with index n to a DSP stream.
DLL_EXPORT void dsp_stream_add_star(dsp_stream_p stream, dsp_star star)
Add a star to the DSP Stream passed as argument.
DLL_EXPORT void dsp_stream_calc_triangles(dsp_stream_p stream)
Calculate the triangles in the stream struct.
DLL_EXPORT void * dsp_stream_exec(dsp_stream_p stream, void *args,...)
Execute the function callback pointed by the func field of the passed stream.
DLL_EXPORT void dsp_stream_align(dsp_stream_p stream)
Perform scale, translate and rotate transformations in-place.
DLL_EXPORT dsp_t * dsp_stream_get_buffer(dsp_stream_p stream)
Return the buffer of the stream passed as argument.
DLL_EXPORT dsp_stream_p * dsp_stream_from_components(dsp_t *buf, int dims, int *sizes, int components)
Convert a color component dsp_t array into a dsp_stream_p array each element containing the single co...
DLL_EXPORT void dsp_buffer_components_to_rgb(dsp_stream_p *stream, void *rgb, int components, int bpp)
Convert a component dsp_stream_p array into an RGB dsp_t array.
DLL_EXPORT void dsp_file_write_jpeg_composite(const char *filename, int components, int quality, dsp_stream_p *stream)
Write the components dsp_stream_p array into a JPEG file,.
DLL_EXPORT dsp_stream_p * dsp_buffer_rgb_to_components(void *buf, int dims, int *sizes, int components, int bpp, int stretch)
Convert an RGB color dsp_t array into a dsp_stream_p array each element containing the single compone...
DLL_EXPORT dsp_stream_p * dsp_file_read_jpeg(const char *filename, int *channels, int stretch)
Read a JPEG file and fill a array of dsp_stream_p with its content, each color channel has its own st...
DLL_EXPORT dsp_stream_p * dsp_file_read_png(const char *filename, int *channels, int stretch)
Read a PNG file and fill a array of dsp_stream_p with its content, each color channel has its own str...
DLL_EXPORT void dsp_file_write_fits_bayer(const char *filename, int components, int bpp, dsp_stream_p *stream)
Write a FITS file from a dsp_stream_p array.
DLL_EXPORT dsp_stream_p * dsp_file_read_fits(const char *filename, int *channels, int stretch)
Read a FITS file and fill a dsp_stream_p with its content.
DLL_EXPORT void dsp_file_write_fits_composite(const char *filename, int components, int bpp, dsp_stream_p *stream)
Write the components dsp_stream_p array into a JPEG file,.
DLL_EXPORT dsp_t * dsp_file_bayer_2_composite(dsp_t *src, int red, int width, int height)
Convert a bayer pattern dsp_t array into a contiguos component array.
DLL_EXPORT dsp_align_info dsp_align_fill_info(dsp_triangle t1, dsp_triangle t2)
Fill a dsp_align_info struct by comparing two triangles.
DLL_EXPORT void dsp_file_write_jpeg(const char *filename, int quality, dsp_stream_p stream)
Write the stream into a JPEG file,.
DLL_EXPORT dsp_t * dsp_file_bayer_2_rgb(dsp_t *src, int red, int width, int height)
Convert a bayer pattern dsp_t array into a ordered 3 RGB array.
DLL_EXPORT dsp_t * dsp_file_bayer_2_gray(dsp_t *src, int width, int height)
Convert a bayer pattern dsp_t array into a grayscale array.
DLL_EXPORT int dsp_align_get_offset(dsp_stream_p ref, dsp_stream_p to_align, double tolerance, double target_score)
Calculate offsets, rotation and scaling of two streams giving reference alignment point.
DLL_EXPORT dsp_t * dsp_file_composite_2_bayer(dsp_stream_p *src, int red, int width, int height)
Convert a component dsp_stream_p array into a bayer dsp_t array.
DLL_EXPORT void dsp_file_write_png_composite(const char *filename, int components, int compression, dsp_stream_p *stream)
Write the components dsp_stream_p array into a PNG file,.
DLL_EXPORT void dsp_file_write_fits(const char *filename, int bpp, dsp_stream_p stream)
Write the dsp_stream_p into a FITS file,.
DLL_EXPORT dsp_triangle dsp_align_calc_triangle(dsp_star *stars)
Create a dsp_triangle struct.
DLL_EXPORT void dsp_filter_lowpass(dsp_stream_p stream, double frequency)
A low pass filter.
DLL_EXPORT void dsp_filter_bandreject(dsp_stream_p stream, double LowFrequency, double HighFrequency)
A band reject filter.
DLL_EXPORT void dsp_filter_bandpass(dsp_stream_p stream, double LowFrequency, double HighFrequency)
A band pass filter.
DLL_EXPORT void dsp_filter_highpass(dsp_stream_p stream, double frequency)
A high pass filter.
DLL_EXPORT void dsp_filter_squarelaw(dsp_stream_p stream)
A square law filter.
DLL_EXPORT void dsp_fourier_idft(dsp_stream_p stream)
Perform an inverse discrete Fourier Transform of a dsp_stream.
DLL_EXPORT void dsp_fourier_2complex_t(dsp_stream_p stream)
Obtain the complex fourier tranform from the current magnitude and phase buffers.
DLL_EXPORT void dsp_fourier_phase_mag_array_get_complex(double *mag, double *phi, complex_t *out, int len)
Obtain a complex array from phase and magnitude arrays.
DLL_EXPORT void dsp_fourier_2dsp(dsp_stream_p stream)
Fill the magnitude and phase buffers with the current data in stream->dft.
DLL_EXPORT double * dsp_fourier_complex_array_get_phase(dsp_complex in, int len)
Obtain a complex number's array phases.
DLL_EXPORT void dsp_fourier_dft(dsp_stream_p stream, int exp)
Perform a discrete Fourier Transform of a dsp_stream.
DLL_EXPORT double * dsp_fourier_complex_array_get_magnitude(dsp_complex in, int len)
Obtain a complex number's array magnitudes.
DLL_EXPORT void dsp_signals_sawtoothwave(dsp_stream_p stream, double samplefreq, double freq)
Generate a sawtooth wave.
DLL_EXPORT void dsp_signals_sinewave(dsp_stream_p stream, double samplefreq, double freq)
Generate a sinusoidal wave.
DLL_EXPORT void dsp_signals_triwave(dsp_stream_p stream, double samplefreq, double freq)
Generate a triangular wave.
DLL_EXPORT void dsp_modulation_amplitude(dsp_stream_p stream, double samplefreq, double freq)
Generate an amplitude modulated wave.
DLL_EXPORT void dsp_modulation_frequency(dsp_stream_p stream, double samplefreq, double freq, double bandwidth)
Generate a frequency modulated wave.
DLL_EXPORT void dsp_signals_whitenoise(dsp_stream_p stream)
Generate white noise.
DLL_EXPORT double * dsp_stats_histogram(dsp_stream_p stream, int size)
Histogram of the inut stream.
Alignment informations needed.
Definition: dsp.h:270
Indicates an offset.
Definition: dsp.h:227
Indicates a dot or line inside a dsp_stream.
Definition: dsp.h:216
Delimits a region in a single dimension of a buffer.
Definition: dsp.h:317
A star or object contained into a buffer.
Definition: dsp.h:238
Contains a set of informations and data relative to a buffer and how to use it.
Definition: dsp.h:363
A star or object contained into a buffer.
Definition: dsp.h:251
Complex number array struct, used in Fourier Transform functions.
Definition: dsp.h:298
The location type.
Definition: dsp.h:328