Instrument Neutral Distributed Interface INDI 2.2.5
dsp.h
Go to the documentation of this file.
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#ifdef _WIN32
28#define DLL_EXPORT __declspec(dllexport)
29#else
30#define DLL_EXPORT extern
31#endif
32#endif
33
34#if defined(__linux__) || defined(_WIN32) || defined(__CYGWIN__)
35#include <endian.h>
36#else
37#define __bswap_16(a) __builtin_bswap16(a)
38#define __bswap_32(a) __builtin_bswap32(a)
39#define __bswap_64(a) __builtin_bswap64(a)
40#endif
41#include <stdio.h>
42#include <stdlib.h>
43#include <string.h>
44#include <math.h>
45#include <float.h>
46#include <sys/types.h>
47#include <time.h>
48#include <assert.h>
49#include <pthread.h>
50#include <time.h>
51#ifndef M_PI
52 #define M_PI 3.14159265358979323846
53#endif
54
75#define DSP_MAX_STARS 200
76typedef double dsp_t;
77typedef double complex_t[2];
78#define dsp_t_max 255
79#define dsp_t_min -dsp_t_max
80#define DSP_NAME_SIZE 128
81
87DLL_EXPORT unsigned long int dsp_max_threads(unsigned long value);
88
89#ifndef DSP_DEBUG
90#define DSP_DEBUG
95DLL_EXPORT void dsp_set_debug_level(int value);
105DLL_EXPORT void dsp_set_app_name(char* name);
115DLL_EXPORT void dsp_set_stdout(FILE *f);
120DLL_EXPORT void dsp_set_stderr(FILE *f);
121
127DLL_EXPORT void dsp_print(int x, char* str);
128
129#define DSP_DEBUG_INFO 0
130#define DSP_DEBUG_ERROR 1
131#define DSP_DEBUG_WARNING 2
132#define DSP_DEBUG_DEBUG 3
133#define pdbg(x, ...) ({ \
134char str[500]; \
135struct timespec ts; \
136time_t t = time(NULL); \
137struct tm tm = *localtime(&t); \
138clock_gettime(CLOCK_REALTIME, &ts); \
139sprintf(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); \
140switch(x) { \
141 case DSP_DEBUG_ERROR: \
142 sprintf(&str[strlen(str)], "ERRO]"); \
143 break; \
144 case DSP_DEBUG_WARNING: \
145 sprintf(&str[strlen(str)], "WARN]"); \
146 break; \
147 case DSP_DEBUG_DEBUG: \
148 sprintf(&str[strlen(str)], "DEBG]"); \
149 break; \
150 default: \
151 sprintf(&str[strlen(str)], "INFO]"); \
152 break; \
153} \
154if(dsp_get_app_name() != NULL) \
155 sprintf(&str[strlen(str)], "[%s]", dsp_get_app_name()); \
156sprintf(&str[strlen(str)], " "); \
157sprintf(&str[strlen(str)], __VA_ARGS__); \
158dsp_print(x, str); \
159})
160#define pinfo(...) pdbg(DSP_DEBUG_INFO, __VA_ARGS__)
161#define perr(...) pdbg(DSP_DEBUG_ERROR, __VA_ARGS__)
162#define pwarn(...) pdbg(DSP_DEBUG_WARNING, __VA_ARGS__)
163#define pgarb(...) pdbg(DSP_DEBUG_DEBUG, __VA_ARGS__)
164#define pfunc pgarb("%s\n", __func__)
165#define start_gettime
166#define end_gettime
167#else
168#define pinfo(...)
169#define perr(...)
170#define pwarn(...)
171#define pgarb(...)
172#define pfunc(...)
173#define start_gettime(...)
174#define end_gettime(...)
175#endif
176
177
179#ifndef Min
180#define Min(a,b) \
181 ({ __typeof (a) _a = (a); \
182 __typeof (a) _b = (b); \
183 _a < _b ? _a : _b; })
184#endif
186#ifndef Max
187#define Max(a,b) \
188 ({ __typeof (a) _a = (a); \
189 __typeof (a) _b = (b); \
190 _a > _b ? _a : _b; })
191#endif
193#ifndef Log
194#define Log(a,b) \
195( log(a) / log(b) )
196#endif
197#ifndef DSP_ALIGN_TRANSLATED
199#define DSP_ALIGN_TRANSLATED 1
200#endif
201#ifndef DSP_ALIGN_SCALED
203#define DSP_ALIGN_SCALED 2
204#endif
205#ifndef DSP_ALIGN_ROTATED
207#define DSP_ALIGN_ROTATED 4
208#endif
209#ifndef DSP_ALIGN_NO_MATCH
211#define DSP_ALIGN_NO_MATCH 8
212#endif
223typedef struct dsp_point_t
224{
226 double* location;
228 int dims;
230
234typedef struct dsp_offset_t
235{
237 double* offset;
239 int dims;
241
245typedef struct dsp_star_t
246{
250 double diameter;
252 double peak;
254 double flux;
256 double theta;
260
264typedef struct dsp_triangle_t
265{
267 double index;
269 int dims;
271 double *theta;
273 double *sizes;
275 double *ratios;
281
285typedef struct dsp_align_info_t
286{
288 double* offset;
290 double* center;
292 double* radians;
294 double* factor;
296 int dims;
302 double score;
304 double decimals;
306 int err;
308
313typedef union
314{
316 struct
317 {
319 double real;
321 double imaginary;
322 } *complex;
326 double *buf;
328
332typedef struct dsp_region_t
333{
335 int start;
337 int len;
339
343typedef union dsp_location_t
344{
346 struct
347 {
348 double x;
349 double y;
350 double z;
353 struct
354 {
355 double lon;
356 double lat;
357 double el;
360 double coordinates[3];
362
366typedef void *(*dsp_func_t) (void *, ...);
367
445
457DLL_EXPORT void dsp_fourier_dft(dsp_stream_p stream, int exp);
458
464
470
476
485DLL_EXPORT void dsp_fourier_phase_mag_array_get_complex(double* mag, double* phi, complex_t *out, int len);
486
494
502
513
519DLL_EXPORT void dsp_filter_lowpass(dsp_stream_p stream, double frequency);
520
526DLL_EXPORT void dsp_filter_highpass(dsp_stream_p stream, double frequency);
527
534DLL_EXPORT void dsp_filter_bandpass(dsp_stream_p stream, double LowFrequency,
535 double HighFrequency);
536
543DLL_EXPORT void dsp_filter_bandreject(dsp_stream_p stream, double LowFrequency,
544 double HighFrequency);
545
557
564
571#ifndef dsp_stats_min
578#define dsp_stats_min(buf, len)\
579({\
580 int i;\
581 __typeof(buf[0]) min = (__typeof(buf[0]))buf[0];\
582 for(i = 0; i < len; i++) {\
583 min = Min(buf[i], min);\
584 }\
585 min;\
586 })
587#endif
588
589#ifndef dsp_stats_max
596#define dsp_stats_max(buf, len)\
597({\
598 int i;\
599 __typeof(buf[0]) max = (__typeof(buf[0]))buf[0];\
600 for(i = 0; i < len; i++) {\
601 max = Max(buf[i], max);\
602 }\
603 max;\
604 })
605#endif
606
607#ifndef dsp_stats_mid
614#define dsp_stats_mid(buf, len)\
615({\
616 int i;\
617 __typeof(buf[0]) min = dsp_stats_min(buf, len);\
618 (__typeof(buf[0]))(min - dsp_stats_max(buf, len)) / 2.0 + min;\
619})
620#endif
621
622#ifndef dsp_stats_maximum_index
629#define dsp_stats_minimum_index(buf, len)\
630({\
631 int i;\
632 __typeof(buf[0]) min = dsp_stats_min(buf, len);\
633 for(i = 0; i < len; i++) {\
634 if(buf[i] == min) break;\
635 }\
636 i;\
637 })
638#endif
639
640#ifndef dsp_stats_maximum_index
647#define dsp_stats_maximum_index(buf, len)\
648({\
649 int i;\
650 __typeof(buf[0]) max = dsp_stats_max(buf, len);\
651 for(i = 0; i < len; i++) {\
652 if(buf[i] == max) break;\
653 }\
654 i;\
655 })
656#endif
657
658#ifndef dsp_stats_stddev
665#define dsp_stats_mean(buf, len)\
666({\
667 int __dsp__i;\
668 double __dsp__mean = 0;\
669 for(__dsp__i = 0; __dsp__i < len; __dsp__i++) {\
670 __dsp__mean += buf[__dsp__i];\
671 }\
672 __dsp__mean /= len;\
673 __dsp__mean;\
674 })
675#endif
676
677#ifndef dsp_stats_stddev
683#define dsp_stats_stddev(buf, len)\
684({\
685 double __dsp__mean = dsp_stats_mean(buf, len);\
686 int __dsp__x;\
687 double __dsp__stddev = 0;\
688 for(__dsp__x = 0; __dsp__x < len; __dsp__x++) {\
689 __dsp__stddev += fabs(buf[__dsp__x] - __dsp__mean);\
690 }\
691 __dsp__stddev /= len;\
692 __dsp__stddev;\
693 })
694#endif
695
696#ifndef dsp_stats_val_count
704#define dsp_stats_val_count(buf, len, val) \
705({\
706 int x;\
707 int count = 0;\
708 for(x = 0; x < len; x++) {\
709 if(buf[x] == val)\
710 count ++;\
711 }\
712 count;\
713 })
714#endif
715
716#ifndef dsp_stats_val_sum
723#define dsp_stats_val_sum(buf, len) \
724({\
725 int x;\
726 double sum = 0;\
727 for(x = 0; x < len; x++) {\
728 sum += buf[x];\
729 }\
730 sum;\
731 })
732#endif
733
734#ifndef dsp_stats_range_count
743#define dsp_stats_range_count(buf, len, lo, hi) \
744({\
745 int x;\
746 int count = 0;\
747 for(x = 0; x < len; x++) {\
748 if(buf[x] < hi && buf[x] >= lo)\
749 count ++;\
750 }\
751 count;\
752 })
753#endif
754
755#ifndef dsp_stats_compare
763#define dsp_stats_compare(in1, in2, len)\
764({\
765 __typeof(in1[0]) out = 0;\
766 for(int i = 0; i < len; i++) {\
767 out += in1[i] - (__typeof(in1[0]))in2[i];\
768 }\
769 out;\
770 })
771#endif
772
780DLL_EXPORT double* dsp_stats_histogram(dsp_stream_p stream, int size);
781
793
799
800#ifndef dsp_buffer_stretch
808#define dsp_buffer_stretch(buf, len, _mn, _mx)\
809({\
810 int k;\
811 __typeof(buf[0]) __mn = dsp_stats_min(buf, len);\
812 __typeof(buf[0]) __mx = dsp_stats_max(buf, len);\
813 double oratio = (_mx - _mn);\
814 double iratio = (__mx - __mn);\
815 if(iratio == 0) iratio = 1;\
816 for(k = 0; k < len; k++) {\
817 buf[k] -= __mn;\
818 buf[k] = (__typeof(buf[0]))((double)buf[k] * oratio / iratio);\
819 buf[k] += _mn;\
820 }\
821})
822#endif
823
824#ifndef dsp_buffer_set
831#define dsp_buffer_set(buf, len, _val)\
832({\
833 int k;\
834 for(k = 0; k < len; k++) {\
835 buf[k] = (__typeof(buf[0]))(_val);\
836 }\
837})
838#endif
839
840#ifndef dsp_buffer_normalize
848#define dsp_buffer_normalize(buf, len, mn, mx)\
849({\
850 int k;\
851 for(k = 0; k < len; k++) {\
852 buf[k] = Max(mn, Min(mx, buf[k]));\
853 }\
854})
855#endif
856
863DLL_EXPORT void dsp_buffer_max(dsp_stream_p stream, dsp_t* in, int len);
864
871DLL_EXPORT void dsp_buffer_min(dsp_stream_p stream, dsp_t* in, int len);
872
879DLL_EXPORT void dsp_buffer_sub(dsp_stream_p stream, dsp_t* in, int len);
880
887DLL_EXPORT void dsp_buffer_sum(dsp_stream_p stream, dsp_t* in, int len);
888
895DLL_EXPORT void dsp_buffer_div(dsp_stream_p stream, dsp_t* in, int len);
896
903DLL_EXPORT void dsp_buffer_mul(dsp_stream_p stream, dsp_t* in, int len);
904
911DLL_EXPORT void dsp_buffer_pow(dsp_stream_p stream, dsp_t* in, int len);
912
919DLL_EXPORT void dsp_buffer_log(dsp_stream_p stream, dsp_t* in, int len);
920
927
934
941
947DLL_EXPORT void dsp_buffer_div1(dsp_stream_p stream, double val);
948
954DLL_EXPORT void dsp_buffer_1div(dsp_stream_p stream, double val);
955
961DLL_EXPORT void dsp_buffer_mul1(dsp_stream_p stream, double val);
962
968DLL_EXPORT void dsp_buffer_pow1(dsp_stream_p stream, double val);
969
975DLL_EXPORT void dsp_buffer_log1(dsp_stream_p stream, double val);
976
983DLL_EXPORT void dsp_buffer_median(dsp_stream_p stream, int size, int median);
984
990DLL_EXPORT void dsp_buffer_sigma(dsp_stream_p stream, int size);
991
999DLL_EXPORT void dsp_buffer_deviate(dsp_stream_p stream, dsp_t* deviation, dsp_t mindeviation, dsp_t maxdeviation);
1000
1001#ifndef dsp_buffer_reverse
1007#define dsp_buffer_reverse(buf, len) \
1008 ({ \
1009 int i = (len - 1) / 2; \
1010 int j = i + 1; \
1011 __typeof(buf[0]) _x; \
1012 while(i >= 0) \
1013 { \
1014 _x = buf[j]; \
1015 buf[j] = buf[i]; \
1016 buf[i] = _x; \
1017 i--; \
1018 j++; \
1019 } \
1020 })
1021#endif
1022
1023#ifndef dsp_buffer_swap
1029#define dsp_buffer_swap(in, len) \
1030 ({ \
1031 int k; \
1032 switch(sizeof(((__typeof (in[0])*)in)[0])) { \
1033 case 2: \
1034 for(k = 0; k < len; k++) \
1035 ((__typeof (in[0])*)in)[k] = __bswap_16(((__typeof (in[0])*)in)[k]); \
1036 break; \
1037 case 3: \
1038 for(k = 0; k < len; k++) \
1039 ((__typeof (in[0])*)in)[k] = __bswap_32(((__typeof (in[0])*)in)[k]); \
1040 break; \
1041 } \
1042 })
1043#endif
1044
1045#ifndef dsp_buffer_copy
1054#define dsp_buffer_copy(in, out, len) \
1055 ({ \
1056 int k; \
1057 for(k = 0; k < len; k++) { \
1058 ((__typeof (out[0])*)out)[k] = (__typeof (out[0]))((__typeof (in[0])*)in)[k]; \
1059 } \
1060 })
1061#endif
1062
1063#ifndef dsp_buffer_copy_stepping
1075#define dsp_buffer_copy_stepping(in, out, inlen, outlen, instep, outstep) \
1076 ({ \
1077 int k; \
1078 int t; \
1079 for(k = 0, t = 0; k < inlen && t < outlen; k+=instep, t+=outstep) { \
1080 ((__typeof (out[0])*)out)[t] = (__typeof (out[0]))((__typeof (in[0])*)in)[k]; \
1081 } \
1082 })
1083#endif
1084
1097
1104DLL_EXPORT void dsp_stream_set_buffer(dsp_stream_p stream, void *buffer, int len);
1105
1112
1118
1125
1132
1140
1149
1158
1166DLL_EXPORT void dsp_stream_del_star(dsp_stream_p stream, int n);
1167
1176
1184DLL_EXPORT void dsp_stream_del_triangle(dsp_stream_p stream, int index);
1185
1193
1201DLL_EXPORT void dsp_stream_del_child(dsp_stream_p stream, int n);
1202
1211
1220DLL_EXPORT void dsp_stream_set_dim(dsp_stream_p stream, int dim, int size);
1221
1229DLL_EXPORT void dsp_stream_del_dim(dsp_stream_p stream, int n);
1230
1241DLL_EXPORT int dsp_stream_set_position(dsp_stream_p stream, int *pos);
1242
1253DLL_EXPORT int* dsp_stream_get_position(dsp_stream_p stream, int index);
1254
1264DLL_EXPORT void *dsp_stream_exec(dsp_stream_p stream, void *args, ...);
1265
1271
1277
1284
1291
1298
1304
1310
1316
1328
1335DLL_EXPORT void dsp_signals_sinewave(dsp_stream_p stream, double samplefreq, double freq);
1336
1343DLL_EXPORT void dsp_signals_sawtoothwave(dsp_stream_p stream, double samplefreq, double freq);
1344
1351DLL_EXPORT void dsp_signals_triwave(dsp_stream_p stream, double samplefreq, double freq);
1352
1360DLL_EXPORT void dsp_modulation_frequency(dsp_stream_p stream, double samplefreq, double freq, double bandwidth);
1361
1368DLL_EXPORT void dsp_modulation_amplitude(dsp_stream_p stream, double samplefreq, double freq);
1369
1386
1400DLL_EXPORT dsp_stream_p* dsp_file_read_fits(const char* filename, int *channels, int stretch);
1401
1408DLL_EXPORT void dsp_file_write_fits(const char* filename, int bpp, dsp_stream_p stream);
1409
1417DLL_EXPORT void dsp_file_write_fits_composite(const char* filename, int components, int bpp, dsp_stream_p* stream);
1418
1427DLL_EXPORT dsp_stream_p* dsp_file_read_jpeg(const char* filename, int *channels, int stretch);
1428
1435DLL_EXPORT void dsp_file_write_jpeg(const char* filename, int quality, dsp_stream_p stream);
1436
1444DLL_EXPORT void dsp_file_write_jpeg_composite(const char* filename, int components, int quality, dsp_stream_p* stream);
1445
1454DLL_EXPORT dsp_stream_p* dsp_file_read_png(const char* filename, int *channels, int stretch);
1455
1463DLL_EXPORT void dsp_file_write_png_composite(const char* filename, int components, int compression, dsp_stream_p* stream);
1464
1472DLL_EXPORT dsp_t* dsp_file_bayer_2_gray(dsp_t* src, int width, int height);
1473
1482DLL_EXPORT dsp_t* dsp_file_bayer_2_rgb(dsp_t *src, int red, int width, int height);
1483
1493
1504DLL_EXPORT dsp_stream_p *dsp_buffer_rgb_to_components(void* buf, int dims, int *sizes, int components, int bpp, int stretch);
1505
1513DLL_EXPORT void dsp_buffer_components_to_rgb(dsp_stream_p *stream, void* rgb, int components, int bpp);
1514
1523DLL_EXPORT dsp_t* dsp_file_composite_2_bayer(dsp_stream_p *src, int red, int width, int height);
1524
1532DLL_EXPORT void dsp_file_write_fits_bayer(const char* filename, int components, int bpp, dsp_stream_p* stream);
1533
1542DLL_EXPORT dsp_t* dsp_file_bayer_2_composite(dsp_t *src, int red, int width, int height);
1543
1551
1559
1565
1575DLL_EXPORT int dsp_align_get_offset(dsp_stream_p ref, dsp_stream_p to_align, double tolerance, double target_score, int num_stars);
1576
1579#include <fits_extensions.h>
1580
1581#ifdef __cplusplus
1582}
1583#endif
1584
1585#endif //_DSP_H
#define DLL_EXPORT
Definition dsp.h:30
DLL_EXPORT int dsp_get_debug_level()
get the debug level
Definition stream.c:68
DLL_EXPORT void dsp_set_stderr(FILE *f)
set the error log streeam
Definition stream.c:45
DLL_EXPORT char * dsp_get_app_name()
get the application name
Definition stream.c:73
#define DSP_NAME_SIZE
Definition dsp.h:80
DLL_EXPORT unsigned long int dsp_max_threads(unsigned long value)
get/set the maximum number of threads allowed
Definition stream.c:31
double dsp_t
Definition dsp.h:76
double complex_t[2]
Definition dsp.h:77
DLL_EXPORT void dsp_set_debug_level(int value)
set the debug level
Definition stream.c:58
DLL_EXPORT void dsp_set_stdout(FILE *f)
set the output log streeam
Definition stream.c:40
DLL_EXPORT void dsp_print(int x, char *str)
log a message to the error or output streams
Definition stream.c:50
DLL_EXPORT void dsp_set_app_name(char *name)
set the application name
Definition stream.c:63
void *(* dsp_func_t)(void *,...)
Multi-dimensional processing delegate function.
Definition dsp.h:366
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_stream_t * dsp_stream_p
struct dsp_triangle_t dsp_triangle
A star or object contained into a buffer.
struct dsp_align_info_t dsp_align_info
Alignment information needed.
struct dsp_stream_t dsp_stream
Contains a set of information 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:429
double samplerate
Sample rate of the buffers.
Definition dsp.h:421
void * arg
Optional argument for the func() callback.
Definition dsp.h:395
int stars_count
The number of stars of the triangle.
Definition dsp.h:279
double imaginary
Imaginary part of the complex number.
Definition dsp.h:321
char name[DSP_NAME_SIZE]
Friendly name of the stream.
Definition dsp.h:381
int err
Errors.
Definition dsp.h:306
double * pixel_sizes
Sensor size.
Definition dsp.h:419
dsp_point center
The center of the star.
Definition dsp.h:248
int frame_number
Frame number (if part of a series)
Definition dsp.h:443
int triangles_count
Triangles of stars or objects quantity.
Definition dsp.h:439
int dims
Dimensions limit.
Definition dsp.h:296
double * factor
Scaling factor.
Definition dsp.h:294
double decimals
Decimals.
Definition dsp.h:304
double wavelength
Wavelength observed, used as reference with signal generators or filters.
Definition dsp.h:409
double theta
The deviation of the star.
Definition dsp.h:256
double focal_ratio
Focal ratio.
Definition dsp.h:411
int start
Starting point within the buffer.
Definition dsp.h:335
double * center
Center of rotation coordinates.
Definition dsp.h:290
struct dsp_stream_t * parent
The parent stream.
Definition dsp.h:397
int * sizes
Sizes of each dimension.
Definition dsp.h:389
double * location
Center of the point.
Definition dsp.h:226
dsp_complex dft
Fourier transform.
Definition dsp.h:393
int red
Red pixel (Bayer)
Definition dsp.h:417
double * radians
Rotational offset.
Definition dsp.h:292
double index
The index of the triangle.
Definition dsp.h:267
dsp_star * stars
Stars or objects identified into the buffers - TODO.
Definition dsp.h:433
struct dsp_location_t::@415 geographic
The location in geographic coordinates.
struct timespec starttimeutc
Time at the beginning of the stream.
Definition dsp.h:407
dsp_star * stars
The stars of the triangle.
Definition dsp.h:277
double * sizes
The sizes of the triangle.
Definition dsp.h:273
double * buf
Linear double array containing complex numbers.
Definition dsp.h:326
double * target
Target coordinates.
Definition dsp.h:405
int stars_count
Stars or objects quantity.
Definition dsp.h:435
struct dsp_stream_t * magnitude
Fourier transform magnitude.
Definition dsp.h:427
double diameter
The diameter of the star.
Definition dsp.h:250
int dims
The dimensions of the triangle.
Definition dsp.h:269
double x
Definition dsp.h:348
double coordinates[3]
A 3d double array containing the location.
Definition dsp.h:360
double * theta
The inclination of the triangle.
Definition dsp.h:271
double diameter
Diameter.
Definition dsp.h:413
dsp_align_info align_info
Align/scale/rotation settings.
Definition dsp.h:441
dsp_triangle * triangles
Triangles of stars or objects.
Definition dsp.h:437
dsp_func_t func
Callback function.
Definition dsp.h:425
struct dsp_location_t::@414 xyz
The location in xyz coordinates.
int dims
Dimensions limit of the point.
Definition dsp.h:239
double lat
Definition dsp.h:356
int dims
Number of dimensions of the buffers.
Definition dsp.h:387
double lon
Definition dsp.h:355
dsp_location * location
Location coordinates pointer, can be extended to the main buffer size as location companion.
Definition dsp.h:403
double * offset
Center of the point.
Definition dsp.h:237
struct dsp_stream_t ** children
Children streams.
Definition dsp.h:399
double el
Definition dsp.h:357
dsp_t * buf
buffer
Definition dsp.h:391
int len
Length of the region.
Definition dsp.h:337
int triangles_count
Triangles quantity.
Definition dsp.h:300
double SNR
SNR.
Definition dsp.h:415
char name[DSP_NAME_SIZE]
The name of the star.
Definition dsp.h:258
int dims
Dimensions limit of the point.
Definition dsp.h:228
int child_count
Children streams count.
Definition dsp.h:401
double score
Match score.
Definition dsp.h:302
double z
Definition dsp.h:350
double peak
The peak of the star.
Definition dsp.h:252
int is_copy
Increments by one on the copied stream.
Definition dsp.h:383
double * ratios
The sizes of the triangle.
Definition dsp.h:275
dsp_triangle triangles[2]
Reference triangles.
Definition dsp.h:298
dsp_region * ROI
Regions of interest for each dimension.
Definition dsp.h:431
int len
The buffers length.
Definition dsp.h:385
pthread_t thread
Thread type for future usage.
Definition dsp.h:423
double flux
The flux of the star.
Definition dsp.h:254
double real
Real part of the complex number.
Definition dsp.h:319
double * offset
Translation offset.
Definition dsp.h:288
double y
Definition dsp.h:349
complex_t * pairs
Complex number type array used with libFFTW.
Definition dsp.h:324
DLL_EXPORT void dsp_buffer_sum(dsp_stream_p stream, dsp_t *in, int len)
Sum elements of one stream to another's.
Definition buffer.c:68
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.
Definition buffer.c:134
DLL_EXPORT void dsp_buffer_median(dsp_stream_p stream, int size, int median)
Median elements of the input stream.
Definition buffer.c:280
DLL_EXPORT void dsp_buffer_shift(dsp_stream_p stream)
Shift a stream on each dimension.
Definition buffer.c:24
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.
Definition buffer.c:391
DLL_EXPORT void dsp_buffer_div1(dsp_stream_p stream, double val)
Divide elements of the input stream to a value.
Definition buffer.c:185
DLL_EXPORT void dsp_buffer_removemean(dsp_stream_p stream)
Subtract mean from stream.
Definition buffer.c:47
DLL_EXPORT void dsp_buffer_1sub(dsp_stream_p stream, dsp_t val)
Subtract each element of the input stream a value.
Definition buffer.c:145
DLL_EXPORT void dsp_buffer_max(dsp_stream_p stream, dsp_t *in, int len)
Subtract elements of one stream from another's.
Definition buffer.c:79
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.
Definition buffer.c:358
DLL_EXPORT void dsp_buffer_div(dsp_stream_p stream, dsp_t *in, int len)
Divide elements of one stream to another's.
Definition buffer.c:101
DLL_EXPORT void dsp_buffer_sum1(dsp_stream_p stream, dsp_t val)
Sum elements of the input stream to a value.
Definition buffer.c:165
DLL_EXPORT void dsp_buffer_mul(dsp_stream_p stream, dsp_t *in, int len)
Multiply elements of one stream to another's.
Definition buffer.c:112
DLL_EXPORT void dsp_buffer_pow1(dsp_stream_p stream, double val)
Expose elements of the input stream to the given power.
Definition buffer.c:205
DLL_EXPORT void dsp_buffer_log1(dsp_stream_p stream, double val)
Logarithm elements of the input stream using the given base.
Definition buffer.c:215
DLL_EXPORT void dsp_buffer_pow(dsp_stream_p stream, dsp_t *in, int len)
Expose elements of one stream to another's.
Definition buffer.c:123
DLL_EXPORT void dsp_buffer_min(dsp_stream_p stream, dsp_t *in, int len)
Sum elements of one stream to another's.
Definition buffer.c:90
DLL_EXPORT void dsp_buffer_1div(dsp_stream_p stream, double val)
Divide a value to each element of the input stream.
Definition buffer.c:175
DLL_EXPORT void dsp_buffer_sub(dsp_stream_p stream, dsp_t *in, int len)
Subtract elements of one stream from another's.
Definition buffer.c:57
DLL_EXPORT void dsp_buffer_sub1(dsp_stream_p stream, dsp_t val)
Subtract a value from elements of the input stream.
Definition buffer.c:155
DLL_EXPORT void dsp_buffer_mul1(dsp_stream_p stream, double val)
Multiply elements of the input stream to a value.
Definition buffer.c:195
DLL_EXPORT void dsp_convolution_correlation(dsp_stream_p stream, dsp_stream_p matrix)
A cross-correlation processor.
Definition convolution.c:42
DLL_EXPORT void dsp_convolution_convolution(dsp_stream_p stream, dsp_stream_p matrix)
A cross-convolution processor.
Definition convolution.c:22
DLL_EXPORT void dsp_stream_free(dsp_stream_p stream)
Free the DSP stream passed as argument.
Definition stream.c:167
DLL_EXPORT void dsp_stream_scale(dsp_stream_p stream)
Scale a stream.
Definition stream.c:669
DLL_EXPORT void dsp_stream_set_dim(dsp_stream_p stream, int dim, int size)
Set a dimension size to a DSP stream.
Definition stream.c:260
DLL_EXPORT void dsp_stream_subtract(dsp_stream_p stream, dsp_stream_p in)
Subtract a stream to another.
Definition stream.c:846
DLL_EXPORT void dsp_stream_rotate(dsp_stream_p stream)
Rotate a stream around an axis and offset.
Definition stream.c:731
DLL_EXPORT void dsp_stream_del_triangle(dsp_stream_p stream, int index)
Remove the triangle with index n to a DSP stream.
Definition stream.c:419
DLL_EXPORT void dsp_stream_sum(dsp_stream_p stream, dsp_stream_p in)
Sum a stream with another.
Definition stream.c:796
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 dsp_stream_p dsp_stream_copy(dsp_stream_p stream)
Create a copy of the DSP stream passed as argument.
Definition stream.c:200
DLL_EXPORT void dsp_stream_add_triangle(dsp_stream_p stream, dsp_triangle triangle)
Add a triangle to the DSP Stream passed as argument.
Definition stream.c:378
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.
Definition stream.c:304
DLL_EXPORT void dsp_stream_multiply(dsp_stream_p stream, dsp_stream_p in)
Multiply a stream with another.
Definition stream.c:821
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_stream_del_dim(dsp_stream_p stream, int n)
Remove the dimension with index n to a DSP stream.
Definition stream.c:280
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.
Definition stream.c:101
DLL_EXPORT void dsp_stream_del_child(dsp_stream_p stream, int n)
Remove the child with index n to a DSP stream.
Definition stream.c:317
DLL_EXPORT dsp_stream_p dsp_stream_new(void)
Allocate a new DSP stream type.
Definition stream.c:128
DLL_EXPORT void dsp_stream_add_dim(dsp_stream_p stream, int len)
Add a dimension with length len to a DSP stream.
Definition stream.c:235
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.
Definition stream.c:78
DLL_EXPORT void dsp_stream_crop(dsp_stream_p stream)
Crop the buffers of the stream passed as argument by reading the ROI field.
Definition stream.c:589
DLL_EXPORT void dsp_stream_translate(dsp_stream_p stream)
Translate a stream.
Definition stream.c:613
DLL_EXPORT void dsp_stream_free_buffer(dsp_stream_p stream)
Free the buffer of the DSP Stream passed as argument.
Definition stream.c:112
DLL_EXPORT void dsp_stream_del_star(dsp_stream_p stream, int n)
Remove the star with index n to a DSP stream.
Definition stream.c:358
DLL_EXPORT void dsp_stream_add_star(dsp_stream_p stream, dsp_star star)
Add a star to the DSP Stream passed as argument.
Definition stream.c:337
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.
Definition stream.c:526
DLL_EXPORT dsp_t * dsp_stream_get_buffer(dsp_stream_p stream)
Return the buffer of the stream passed as argument.
Definition stream.c:107
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...
Definition file.c:1040
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.
Definition file.c:1139
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,.
Definition file.c:603
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...
Definition file.c:1064
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...
Definition file.c:514
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 int dsp_align_get_offset(dsp_stream_p ref, dsp_stream_p to_align, double tolerance, double target_score, int num_stars)
Calculate offsets, rotation and scaling of two streams giving reference alignment point.
Definition align.c:259
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.
Definition file.c:374
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.
Definition file.c:27
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,.
Definition file.c:266
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 contiguous component array.
Definition file.c:850
DLL_EXPORT void dsp_file_write_jpeg(const char *filename, int quality, dsp_stream_p stream)
Write the stream into a JPEG file,.
Definition file.c:552
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.
Definition file.c:946
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.
Definition file.c:648
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.
Definition file.c:744
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 dsp_triangle * dsp_align_calc_triangle(dsp_star *stars, int num_stars)
Create a dsp_triangle struct.
Definition align.c:197
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.
Definition align.c:147
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,.
Definition file.c:164
DLL_EXPORT void dsp_align_free_triangle(dsp_triangle *triangle)
Free a dsp_triangle struct pointer.
Definition align.c:184
DLL_EXPORT void dsp_filter_lowpass(dsp_stream_p stream, double frequency)
A low pass filter.
Definition filters.c:38
DLL_EXPORT void dsp_filter_bandreject(dsp_stream_p stream, double LowFrequency, double HighFrequency)
A band reject filter.
Definition filters.c:86
DLL_EXPORT void dsp_filter_bandpass(dsp_stream_p stream, double LowFrequency, double HighFrequency)
A band pass filter.
Definition filters.c:110
DLL_EXPORT void dsp_filter_highpass(dsp_stream_p stream, double frequency)
A high pass filter.
Definition filters.c:62
DLL_EXPORT void dsp_filter_squarelaw(dsp_stream_p stream)
A square law filter.
Definition filters.c:22
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_2complex_t(dsp_stream_p stream)
Obtain the complex fourier transform from the current magnitude and phase buffers.
Definition fft.c:58
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.
Definition fft.c:115
DLL_EXPORT void dsp_fourier_2dsp(dsp_stream_p stream)
Fill the magnitude and phase buffers with the current data in stream->dft.
Definition fft.c:35
DLL_EXPORT double * dsp_fourier_complex_array_get_phase(dsp_complex in, int len)
Obtain a complex number's array phases.
Definition fft.c:93
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
DLL_EXPORT double * dsp_fourier_complex_array_get_magnitude(dsp_complex in, int len)
Obtain a complex number's array magnitudes.
Definition fft.c:81
DLL_EXPORT void dsp_signals_sawtoothwave(dsp_stream_p stream, double samplefreq, double freq)
Generate a sawtooth wave.
Definition signals.c:48
DLL_EXPORT void dsp_signals_sinewave(dsp_stream_p stream, double samplefreq, double freq)
Generate a sinusoidal wave.
Definition signals.c:31
DLL_EXPORT void dsp_signals_triwave(dsp_stream_p stream, double samplefreq, double freq)
Generate a triangular wave.
Definition signals.c:64
DLL_EXPORT void dsp_modulation_amplitude(dsp_stream_p stream, double samplefreq, double freq)
Generate an amplitude modulated wave.
Definition signals.c:98
DLL_EXPORT void dsp_modulation_frequency(dsp_stream_p stream, double samplefreq, double freq, double bandwidth)
Generate a frequency modulated wave.
Definition signals.c:82
DLL_EXPORT void dsp_signals_whitenoise(dsp_stream_p stream)
Generate white noise.
Definition signals.c:22
DLL_EXPORT double * dsp_stats_histogram(dsp_stream_p stream, int size)
Histogram of the inut stream.
Definition stats.c:22
void dsp_recons_align(dsp_stream_p stream, dsp_stream_p matrix)
Try to reconstruct a stream from sub-stream matrices.
Alignment information needed.
Definition dsp.h:286
Indicates an offset.
Definition dsp.h:235
Indicates a dot or line inside a dsp_stream.
Definition dsp.h:224
Delimits a region in a single dimension of a buffer.
Definition dsp.h:333
A star or object contained into a buffer.
Definition dsp.h:246
Contains a set of information and data relative to a buffer and how to use it.
Definition dsp.h:379
A star or object contained into a buffer.
Definition dsp.h:265
Complex number array struct, used in Fourier Transform functions.
Definition dsp.h:314
The location type.
Definition dsp.h:344