Instrument Neutral Distributed Interface INDI  1.9.5
dsp.h
Go to the documentation of this file.
1 /*
2  * libDSP - a digital signal processing library
3  * Copyright (C) 2017 Ilia Platone <info@iliaplatone.com>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (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
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef _DSP_H
20 #define _DSP_H
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 #ifndef DLL_EXPORT
27 #define DLL_EXPORT extern
28 #endif
29 
30 #include <stdio.h>
31 #include <stdlib.h>
32 #include <string.h>
33 #include <math.h>
34 #include <float.h>
35 #include <sys/types.h>
36 #include <time.h>
37 #include <assert.h>
38 #include <pthread.h>
39 
40 
51 
56 #define DSP_MAX_STARS 200
57 #define dsp_t double
58 #define dsp_t_max pow(2, sizeof(dsp_t)*4)
59 #define dsp_t_min -dsp_t_max
60 
61 #define DSP_MAX_THREADS 4
62 
64 #ifndef Min
65 #define Min(a,b) \
66  ({ __typeof__ (a) _a = (a); \
67  __typeof__ (a) _b = (b); \
68  _a < _b ? _a : _b; })
69 #endif
70 #ifndef Max
72 #define Max(a,b) \
73  ({ __typeof__ (a) _a = (a); \
74  __typeof__ (a) _b = (b); \
75  _a > _b ? _a : _b; })
76 #endif
77 #ifndef Log
79 #define Log(a,b) \
80 ( log(a) / log(b) )
81 #endif
82 
87 
92 typedef struct dsp_point_t
93 {
95  double* location;
97  int dims;
98 } dsp_point;
99 
103 typedef struct dsp_offset_t
104 {
106  double* offset;
108  int dims;
109 } dsp_offset;
110 
114 typedef struct dsp_align_info_t
115 {
117  double* offset;
119  double* center;
121  double* radians;
123  double factor;
125  int dims;
127 
133 typedef struct dsp_complex_t
134 {
136  double real;
138  double imaginary;
139 } dsp_complex;
140 
144 typedef struct dsp_region_t
145 {
147  int start;
149  int len;
150 } dsp_region;
151 
155 typedef struct dsp_star_t
156 {
160  double diameter;
161 } dsp_star;
162 
166 typedef void *(*dsp_func_t) (void *, ...);
167 
175 typedef struct dsp_stream_t
176 {
178  int len;
180  int dims;
182  int* sizes;
186  void *arg;
194  double* location;
196  double* target;
198  struct timespec starttimeutc;
200  double wavelength;
202  double focal_ratio;
204  double diameter;
206  double SNR;
208  int red;
210  double *pixel_sizes;
212  double samplerate;
214  pthread_t thread;
228 
234 
240 
246 
252 
258 
265 
272 
280 
288 
294 
300 
306 
312 
323 
330 DLL_EXPORT void dsp_filter_lowpass(dsp_stream_p stream, double samplingfrequency, double frequency);
331 
338 DLL_EXPORT void dsp_filter_highpass(dsp_stream_p stream, double samplingfrequency, double frequency);
339 
347 DLL_EXPORT void dsp_filter_bandpass(dsp_stream_p stream, double samplingfrequency, double LowFrequency, double HighFrequency);
348 
356 DLL_EXPORT void dsp_filter_bandreject(dsp_stream_p stream, double samplingfrequency, double LowFrequency, double HighFrequency);
357 
369 
375 
382 #define dsp_stats_min(buf, len)\
383 ({\
384  int i;\
385  __typeof__(buf[0]) min = (__typeof__(buf[0]))buf[0];\
386  for(i = 0; i < len; i++) {\
387  min = Min(buf[i], min);\
388  }\
389  min;\
390  })
391 
398 #define dsp_stats_max(buf, len)\
399 ({\
400  int i;\
401  __typeof__(buf[0]) max = (__typeof__(buf[0]))buf[0];\
402  for(i = 0; i < len; i++) {\
403  max = Max(buf[i], max);\
404  }\
405  max;\
406  })
407 
414 #define dsp_stats_mid(buf, len)\
415 ({\
416  int i;\
417  __typeof__(buf[0]) min = dsp_stats_min(buf, len);\
418  (__typeof__(buf[0]))(min - dsp_stats_max(buf, len)) / 2.0 + min;\
419 })
420 
427 #define dsp_stats_minimum_index(buf, len)\
428 ({\
429  int i;\
430  __typeof__(buf[0]) min = dsp_stats_min(buf, len);\
431  for(i = 0; i < len; i++) {\
432  if(buf[i] == min) break;\
433  }\
434  i;\
435  })
436 
443 #define dsp_stats_maximum_index(buf, len)\
444 ({\
445  int i;\
446  __typeof__(buf[0]) max = dsp_stats_max(buf, len);\
447  for(i = 0; i < len; i++) {\
448  if(buf[i] == max) break;\
449  }\
450  i;\
451  })
452 
459 #define dsp_stats_mean(buf, len)\
460 ({\
461  int i;\
462  __typeof__(buf[0]) mean = 0;\
463  for(i = 0; i < len; i++) {\
464  mean += buf[i];\
465  }\
466  mean /= len;\
467  mean;\
468  })
469 
477 #define dsp_stats_val_count(buf, len, val) \
478 ({\
479  int x;\
480  int count = 0;\
481  for(x = 0; x < len; x++) {\
482  if(buf[x] == val)\
483  count ++;\
484  }\
485  count;\
486  })
487 
495 #define dsp_stats_range_count(buf, len, lo, hi) \
496 ({\
497  int x;\
498  int count = 0;\
499  for(x = 0; x < len; x++) {\
500  if(buf[x] < hi && buf[x] >= lo)\
501  count ++;\
502  }\
503  count;\
504  })
505 
513 #define dsp_stats_compare(in1, in2, len)\
514 ({\
515  __typeof__(in1[0]) out = 0;\
516  for(int i = 0; i < len; i++) {\
517  out += in1[i] - (__typeof__(in1[0]))in2[i];\
518  }\
519  out;\
520  })
521 
529 DLL_EXPORT double* dsp_stats_histogram(dsp_stream_p stream, int size);
530 
536 
542 
548 
557 #define dsp_buffer_stretch(buf, len, _mn, _mx)\
558 ({\
559  int k;\
560  __typeof__(buf[0]) __mn = dsp_stats_min(buf, len);\
561  __typeof__(buf[0]) __mx = dsp_stats_max(buf, len);\
562  double oratio = (_mx - _mn);\
563  double iratio = (__mx - __mn);\
564  if(iratio == 0) iratio = 1;\
565  for(k = 0; k < len; k++) {\
566  buf[k] -= __mn;\
567  buf[k] = (__typeof__(buf[0]))((double)buf[k] * oratio / iratio);\
568  buf[k] += _mn;\
569  }\
570 })
571 
579 #define dsp_buffer_set(buf, len, _val)\
580 ({\
581  int k;\
582  for(k = 0; k < len; k++) {\
583  buf[k] = (__typeof__(buf[0]))(_val);\
584  }\
585 })
586 
594 #define dsp_buffer_normalize(buf, len, mn, mx)\
595 ({\
596  int k;\
597  for(k = 0; k < len; k++) {\
598  buf[k] = Max(mn, Min(mx, buf[k]));\
599  }\
600 })
601 
608 DLL_EXPORT void dsp_buffer_max(dsp_stream_p stream, dsp_t* in, int len);
609 
616 DLL_EXPORT void dsp_buffer_min(dsp_stream_p stream, dsp_t* in, int len);
617 
624 DLL_EXPORT void dsp_buffer_sub(dsp_stream_p stream, dsp_t* in, int len);
625 
632 DLL_EXPORT void dsp_buffer_sum(dsp_stream_p stream, dsp_t* in, int len);
633 
640 DLL_EXPORT void dsp_buffer_div(dsp_stream_p stream, dsp_t* in, int len);
641 
648 DLL_EXPORT void dsp_buffer_mul(dsp_stream_p stream, dsp_t* in, int len);
649 
656 DLL_EXPORT void dsp_buffer_pow(dsp_stream_p stream, dsp_t* in, int len);
657 
664 DLL_EXPORT void dsp_buffer_log(dsp_stream_p stream, dsp_t* in, int len);
665 
671 DLL_EXPORT void dsp_buffer_sub1(dsp_stream_p stream, double val);
672 
678 DLL_EXPORT void dsp_buffer_1sub(dsp_stream_p stream, double val);
679 
685 DLL_EXPORT void dsp_buffer_sum1(dsp_stream_p stream, double val);
686 
692 DLL_EXPORT void dsp_buffer_div1(dsp_stream_p stream, double val);
693 
699 DLL_EXPORT void dsp_buffer_1div(dsp_stream_p stream, double val);
700 
706 DLL_EXPORT void dsp_buffer_mul1(dsp_stream_p stream, double val);
707 
713 DLL_EXPORT void dsp_buffer_pow1(dsp_stream_p stream, double val);
714 
720 DLL_EXPORT void dsp_buffer_log1(dsp_stream_p stream, double val);
721 
728 DLL_EXPORT void dsp_buffer_median(dsp_stream_p stream, int size, int median);
729 
737 DLL_EXPORT void dsp_buffer_deviate(dsp_stream_p stream, dsp_t* deviation, dsp_t mindeviation, dsp_t maxdeviation);
738 
744 #ifndef dsp_buffer_reverse
745 #define dsp_buffer_reverse(buf, len) \
746  ({ \
747  int i = (len - 1) / 2; \
748  int j = i + 1; \
749  __typeof__(buf[0]) _x; \
750  while(i >= 0) \
751  { \
752  _x = buf[j]; \
753  buf[j] = buf[i]; \
754  buf[i] = _x; \
755  i--; \
756  j++; \
757  } \
758  })
759 #endif
760 
761 #ifndef dsp_buffer_swap
762 #define dsp_buffer_swap(in, len) \
763  ({ \
764  int k; \
765  switch(sizeof(((__typeof__ (in[0])*)in)[0])) { \
766  case 2: \
767  for(k = 0; k < len; k++) \
768  ((__typeof__ (in[0])*)in)[k] = __bswap_16(((__typeof__ (in[0])*)in)[k]); \
769  break; \
770  case 3: \
771  for(k = 0; k < len; k++) \
772  ((__typeof__ (in[0])*)in)[k] = __bswap_32(((__typeof__ (in[0])*)in)[k]); \
773  break; \
774  case 4: \
775  for(k = 0; k < len; k++) \
776  ((__typeof__ (in[0])*)in)[k] = __bswap_64(((__typeof__ (in[0])*)in)[k]); \
777  break; \
778  } \
779  })
780 #endif
781 
790 #ifndef dsp_buffer_copy
791 #define dsp_buffer_copy(in, out, len) \
792  ({ \
793  int k; \
794  for(k = 0; k < len; k++) { \
795  ((__typeof__ (out[0])*)out)[k] = (__typeof__ (out[0]))((__typeof__ (in[0])*)in)[k]; \
796  } \
797  })
798 #endif
799 
810 #ifndef dsp_buffer_copy_stepping
811 #define dsp_buffer_copy_stepping(in, out, inlen, outlen, instep, outstep) \
812  ({ \
813  int k; \
814  int t; \
815  for(k = 0, t = 0; k < inlen && t < outlen; k+=instep, t+=outstep) { \
816  ((__typeof__ (out[0])*)out)[t] = (__typeof__ (out[0]))((__typeof__ (in[0])*)in)[k]; \
817  } \
818  })
819 #endif
820 
826 
832 DLL_EXPORT void dsp_stream_alloc_buffer(dsp_stream_p stream, int len);
833 
840 DLL_EXPORT void dsp_stream_set_buffer(dsp_stream_p stream, void *buffer, int len);
841 
848 
854 
861 
868 
876 
883 
892 
901 
909 DLL_EXPORT void dsp_stream_del_child(dsp_stream_p stream, int n);
910 
918 DLL_EXPORT void dsp_stream_del_star(dsp_stream_p stream, int n);
919 
927 DLL_EXPORT void dsp_stream_add_dim(dsp_stream_p stream, int len);
928 
936 DLL_EXPORT void dsp_stream_del_dim(dsp_stream_p stream, int n);
937 
948 DLL_EXPORT int dsp_stream_set_position(dsp_stream_p stream, int *pos);
949 
960 DLL_EXPORT int* dsp_stream_get_position(dsp_stream_p stream, int index);
961 
970 DLL_EXPORT void *dsp_stream_exec(dsp_stream_p stream, void *args, ...);
971 
979 
985 
991 
998 DLL_EXPORT void dsp_signals_sinewave(dsp_stream_p stream, double samplefreq, double freq);
999 
1006 DLL_EXPORT void dsp_signals_sawtoothwave(dsp_stream_p stream, double samplefreq, double freq);
1007 
1014 DLL_EXPORT void dsp_signals_triwave(dsp_stream_p stream, double samplefreq, double freq);
1015 
1023 DLL_EXPORT void dsp_modulation_frequency(dsp_stream_p stream, double samplefreq, double freq, double bandwidth);
1024 
1031 DLL_EXPORT void dsp_modulation_amplitude(dsp_stream_p stream, double samplefreq, double freq);
1032 
1042 DLL_EXPORT int dsp_align_find_stars(dsp_stream_p stream, int levels, int min_size, float threshold, dsp_stream_p matrix);
1043 
1052 DLL_EXPORT int dsp_align_crop_limit(dsp_stream_p reference, dsp_stream_p to_align, int n, int radius);
1053 
1063 DLL_EXPORT int dsp_align_get_offset(dsp_stream_p stream1, dsp_stream_p stream, int max_stars, int decimals);
1064 
1072 
1080 
1088 
1095 DLL_EXPORT dsp_stream_p* dsp_file_read_fits(char *filename, int *channels, int stretch);
1096 
1104 DLL_EXPORT void* dsp_file_write_fits(int bpp, size_t* memsize, dsp_stream_p stream);
1105 
1114 DLL_EXPORT dsp_stream_p* dsp_file_read_jpeg(char *filename, int *channels, int stretch);
1115 
1123 DLL_EXPORT void dsp_file_write_jpeg_composite(char *filename, int components, int quality, dsp_stream_p* stream);
1124 
1125 DLL_EXPORT dsp_stream_p *dsp_stream_from_components(dsp_t* buf, int dims, int *sizes, int components);
1126 DLL_EXPORT dsp_stream_p *dsp_buffer_rgb_to_components(void* buf, int dims, int *sizes, int components, int bpp, int stretch);
1127 DLL_EXPORT void dsp_buffer_components_to_rgb(dsp_stream_p *stream, void* rgb, int components, int bpp);
1128 
1131 
1132 #ifdef __cplusplus
1133 }
1134 #endif
1135 
1136 #endif //_DSP_H
dsp_buffer_min
DLL_EXPORT void dsp_buffer_min(dsp_stream_p stream, dsp_t *in, int len)
Sum elements of one stream to another's.
dsp_stream_del_child
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:149
dsp_stream_from_components
DLL_EXPORT dsp_stream_p * dsp_stream_from_components(dsp_t *buf, int dims, int *sizes, int components)
Definition: file.c:339
dsp_buffer_rgb_to_components
DLL_EXPORT dsp_stream_p * dsp_buffer_rgb_to_components(void *buf, int dims, int *sizes, int components, int bpp, int stretch)
Definition: file.c:364
dsp_stream_p
struct dsp_stream_t * dsp_stream_p
dsp_filter_lowpass
DLL_EXPORT void dsp_filter_lowpass(dsp_stream_p stream, double samplingfrequency, double frequency)
A low pass filter.
Definition: filters.c:45
dsp_stats_histogram
DLL_EXPORT double * dsp_stats_histogram(dsp_stream_p stream, int size)
Histogram of the inut stream.
Definition: stats.c:21
dsp_filter_bandpass
DLL_EXPORT void dsp_filter_bandpass(dsp_stream_p stream, double samplingfrequency, double LowFrequency, double HighFrequency)
A band pass filter.
Definition: filters.c:107
dsp_align_info_t::center
double * center
Center of rotation coordinates.
Definition: dsp.h:119
dsp_star_t::diameter
double diameter
The diameter of the star.
Definition: dsp.h:160
dsp_align_find_stars
DLL_EXPORT int dsp_align_find_stars(dsp_stream_p stream, int levels, int min_size, float threshold, dsp_stream_p matrix)
Find stars into the stream.
dsp_buffer_median
DLL_EXPORT void dsp_buffer_median(dsp_stream_p stream, int size, int median)
Median elements of the inut stream.
Definition: buffer.c:210
dsp_stream_rotate
DLL_EXPORT void dsp_stream_rotate(dsp_stream_p stream)
Rotate a stream around an axis and offset.
Definition: stream.c:364
dsp_stream_new
DLL_EXPORT dsp_stream_p dsp_stream_new()
Allocate a new DSP stream type.
Definition: stream.c:48
dsp_complex
struct dsp_complex_t dsp_complex
Complex number, used in Fourier Transform functions.
dsp_buffer_sub1
DLL_EXPORT void dsp_buffer_sub1(dsp_stream_p stream, double val)
Subtract a value from elements of the input stream.
Definition: buffer.c:130
dsp_align_info_t::radians
double * radians
Rotational offset.
Definition: dsp.h:121
dsp_modulation_amplitude
DLL_EXPORT void dsp_modulation_amplitude(dsp_stream_p stream, double samplefreq, double freq)
Generate an amplitude modulated wave.
Definition: signals.c:97
dsp_align_get_offset
DLL_EXPORT int dsp_align_get_offset(dsp_stream_p stream1, dsp_stream_p stream, int max_stars, int decimals)
Find offsets between 2 streams and extract align informations.
dsp_stream_t::func
dsp_func_t func
Callback function.
Definition: dsp.h:216
dsp_fourier_complex_get_phase
DLL_EXPORT double dsp_fourier_complex_get_phase(dsp_complex n)
Obtain a complex number's phase.
Definition: fft.c:27
dsp_offset_t::offset
double * offset
Center of the point.
Definition: dsp.h:106
dsp_fourier_idft_phase
DLL_EXPORT void dsp_fourier_idft_phase(dsp_stream_p stream)
Perform an inverse discrete Fourier Transform of a dsp_stream and obtain the complex phases.
dsp_stream_t::wavelength
double wavelength
Wavelength observed, used as reference with signal generators or filters.
Definition: dsp.h:200
dsp_stream_exec
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.
dsp_star_t::center
dsp_point center
The center of the star.
Definition: dsp.h:158
dsp_buffer_removemean
DLL_EXPORT void dsp_buffer_removemean(dsp_stream_p stream)
Subtract mean from stream.
Definition: buffer.c:44
dsp_stream_traslate
DLL_EXPORT void dsp_stream_traslate(dsp_stream_p stream)
Traslate a stream.
Definition: stream.c:252
dsp_stream_t::frame_number
int frame_number
Frame number (if part of a series)
Definition: dsp.h:226
dsp_stream_t::diameter
double diameter
Diameter.
Definition: dsp.h:204
dsp_complex_t::real
double real
Real part of the complex number.
Definition: dsp.h:136
dsp_buffer_log1
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:190
dsp_stream_add_child
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:141
dsp_filter_squarelaw
DLL_EXPORT void dsp_filter_squarelaw(dsp_stream_p stream)
A square law filter.
Definition: filters.c:21
dsp_signals_sinewave
DLL_EXPORT void dsp_signals_sinewave(dsp_stream_p stream, double samplefreq, double freq)
Generate a sinusoidal wave.
Definition: signals.c:30
dsp_file_write_fits
DLL_EXPORT void * dsp_file_write_fits(int bpp, size_t *memsize, dsp_stream_p stream)
Write the components dsp_stream_p array into a FITS file,.
Definition: file.c:147
dsp_align_info_t::dims
int dims
Dimensions limit.
Definition: dsp.h:125
dsp_stream_free
DLL_EXPORT void dsp_stream_free(dsp_stream_p stream)
Free the DSP stream passed as argument.
Definition: stream.c:76
dsp_func_t
void *(* dsp_func_t)(void *,...)
Multi-dimensional processing delegate function.
Definition: dsp.h:166
dsp_buffer_pow1
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:180
dsp_signals_sawtoothwave
DLL_EXPORT void dsp_signals_sawtoothwave(dsp_stream_p stream, double samplefreq, double freq)
Generate a sawtooth wave.
Definition: signals.c:47
dsp_fourier_idft
DLL_EXPORT dsp_t * dsp_fourier_idft(dsp_stream_p stream)
Perform an inverse discrete Fourier Transform of a dsp_stream.
Definition: fft.c:71
dsp_star_t
A star or object contained into a buffer.
Definition: dsp.h:155
dsp_point_t::location
double * location
Center of the point.
Definition: dsp.h:95
dsp_fourier_dft
DLL_EXPORT dsp_complex * dsp_fourier_dft(dsp_stream_p stream)
Perform a discrete Fourier Transform of a dsp_stream.
Definition: fft.c:56
dsp_buffer_1sub
DLL_EXPORT void dsp_buffer_1sub(dsp_stream_p stream, double val)
Subtract each element of the input stream a value.
Definition: buffer.c:120
dsp_fourier_dft_magnitude
DLL_EXPORT void dsp_fourier_dft_magnitude(dsp_stream_p stream)
Perform a discrete Fourier Transform of a dsp_stream and obtain the complex magnitudes.
dsp_stream_t
Contains a set of informations and data relative to a buffer and how to use it.
Definition: dsp.h:175
dsp_point
struct dsp_point_t dsp_point
Indicates a dot or line inside a dsp_stream.
dsp_stream_copy
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:89
dsp_buffer_pow
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:98
dsp_offset
struct dsp_offset_t dsp_offset
Indicates an offset.
dsp_buffer_sum
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:65
dsp_stream_get_buffer
DLL_EXPORT dsp_t * dsp_stream_get_buffer(dsp_stream_p stream)
Return the buffer of the stream passed as argument.
Definition: stream.c:36
dsp_buffer_div1
DLL_EXPORT void dsp_buffer_div1(dsp_stream_p stream, double val)
Divide elements of the input stream to a value.
Definition: buffer.c:160
dsp_buffer_mul
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:87
dsp_region_t::start
int start
Starting point within the buffer.
Definition: dsp.h:147
dsp_stream_t::starttimeutc
struct timespec starttimeutc
Time at the beginning of the stream.
Definition: dsp.h:198
dsp_offset_t
Indicates an offset.
Definition: dsp.h:103
dsp_star
struct dsp_star_t dsp_star
A star or object contained into a buffer.
dsp_file_write_jpeg_composite
DLL_EXPORT void dsp_file_write_jpeg_composite(char *filename, int components, int quality, dsp_stream_p *stream)
Write the components dsp_stream_p array into a JPEG file,.
Definition: file.c:294
dsp_stream_t::align_info
dsp_align_info align_info
Align/scale/rotation settings.
Definition: dsp.h:224
dsp_stream_t::arg
void * arg
Optional argument for the func() callback.
Definition: dsp.h:186
dsp_stream_t::samplerate
double samplerate
Sample rate of the buffers.
Definition: dsp.h:212
dsp_convolution_convolution
DLL_EXPORT dsp_stream_p dsp_convolution_convolution(dsp_stream_p stream1, dsp_stream_p stream2)
A cross-convolution processor.
Definition: convolution.c:45
dsp_stream_scale
DLL_EXPORT void dsp_stream_scale(dsp_stream_p stream)
Scale a stream.
Definition: stream.c:300
dsp_buffer_div
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:76
dsp_stream_t::location
double * location
Location coordinates.
Definition: dsp.h:194
dsp_offset_t::dims
int dims
Dimensions limit of the point.
Definition: dsp.h:108
dsp_align_info_t::offset
double * offset
Traslation offset.
Definition: dsp.h:117
dsp_stream_t::stars
dsp_star * stars
Stars or objects identified into the buffers - TODO.
Definition: dsp.h:220
dsp_stream_set_position
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:202
dsp_file_read_jpeg
DLL_EXPORT dsp_stream_p * dsp_file_read_jpeg(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:256
dsp_stream_t::len
int len
The buffers length.
Definition: dsp.h:178
dsp_filter_highpass
DLL_EXPORT void dsp_filter_highpass(dsp_stream_p stream, double samplingfrequency, double frequency)
A high pass filter.
Definition: filters.c:61
dsp_signals_triwave
DLL_EXPORT void dsp_signals_triwave(dsp_stream_p stream, double samplefreq, double freq)
Generate a triangular wave.
Definition: signals.c:63
dsp_buffer_log
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:109
dsp_stream_t::focal_ratio
double focal_ratio
Focal ratio.
Definition: dsp.h:202
dsp_complex_t
Complex number, used in Fourier Transform functions.
Definition: dsp.h:133
dsp_modulation_frequency
DLL_EXPORT void dsp_modulation_frequency(dsp_stream_p stream, double samplefreq, double freq, double bandwidth)
Generate a frequency modulated wave.
Definition: signals.c:81
dsp_fourier_idft_magnitude
DLL_EXPORT void dsp_fourier_idft_magnitude(dsp_stream_p stream)
Perform an inverse discrete Fourier Transform of a dsp_stream and obtain the complex magnitudes.
dsp_buffer_components_to_rgb
DLL_EXPORT void dsp_buffer_components_to_rgb(dsp_stream_p *stream, void *rgb, int components, int bpp)
Definition: file.c:436
dsp_buffer_shift
DLL_EXPORT void dsp_buffer_shift(dsp_stream_p stream)
Shift a stream on each dimension.
Definition: buffer.c:21
dsp_fourier_complex_get_magnitude
DLL_EXPORT double dsp_fourier_complex_get_magnitude(dsp_complex n)
Obtain a complex number's magnitude.
Definition: fft.c:22
dsp_stream_free_buffer
DLL_EXPORT void dsp_stream_free_buffer(dsp_stream_p stream)
Free the buffer of the DSP Stream passed as argument.
Definition: stream.c:41
dsp_align_crop_limit
DLL_EXPORT int dsp_align_crop_limit(dsp_stream_p reference, dsp_stream_p to_align, int n, int radius)
Limit search area to the radius around the first n stars and store those streams as children of the s...
dsp_filter_bandreject
DLL_EXPORT void dsp_filter_bandreject(dsp_stream_p stream, double samplingfrequency, double LowFrequency, double HighFrequency)
A band reject filter.
Definition: filters.c:77
dsp_stream_t::sizes
int * sizes
Sizes of each dimension.
Definition: dsp.h:182
dsp_buffer_max
DLL_EXPORT void dsp_buffer_max(dsp_stream_p stream, dsp_t *in, int len)
Subtract elements of one stream from another's.
dsp_align_info_t
Alignment informations needed.
Definition: dsp.h:114
dsp_stream_t::thread
pthread_t thread
Thread type for future usage.
Definition: dsp.h:214
dsp_stream_t::SNR
double SNR
SNR.
Definition: dsp.h:206
dsp_stream_alloc_buffer
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:21
dsp_buffer_sum1
DLL_EXPORT void dsp_buffer_sum1(dsp_stream_p stream, double val)
Sum elements of the input stream to a value.
Definition: buffer.c:140
dsp_stream_t::stars_count
int stars_count
Stars or objects quantity.
Definition: dsp.h:222
dsp_stream_t::pixel_sizes
double * pixel_sizes
Sensor size.
Definition: dsp.h:210
dsp_stream_crop
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:213
dsp_fourier_ifft
DLL_EXPORT void dsp_fourier_ifft(dsp_stream_p stream)
Perform an inverse fast Fourier Transform of a dsp_stream.
dsp_buffer_sub
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:54
dsp_fourier_complex_array_get_phase
DLL_EXPORT double * dsp_fourier_complex_array_get_phase(dsp_complex *in, int len)
Obtain a complex number's array phases.
Definition: fft.c:46
dsp_complex_t::imaginary
double imaginary
Imaginary part of the complex number.
Definition: dsp.h:138
dsp_signals_whitenoise
DLL_EXPORT void dsp_signals_whitenoise(dsp_stream_p stream)
Generate white noise.
Definition: signals.c:21
dsp_align_info
struct dsp_align_info_t dsp_align_info
Alignment informations needed.
dsp_stream_set_buffer
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:30
dsp_point_t::dims
int dims
Dimensions limit of the point.
Definition: dsp.h:97
dsp_fourier_fft
DLL_EXPORT void dsp_fourier_fft(dsp_stream_p stream)
Perform a fast Fourier Transform of a dsp_stream.
dsp_point_t
Indicates a dot or line inside a dsp_stream.
Definition: dsp.h:92
dsp_fourier_complex_array_get_magnitude
DLL_EXPORT double * dsp_fourier_complex_array_get_magnitude(dsp_complex *in, int len)
Obtain a complex number's array magnitudes.
Definition: fft.c:36
dsp_stream
struct dsp_stream_t dsp_stream
Contains a set of informations and data relative to a buffer and how to use it.
dsp_buffer_deviate
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:223
dsp_stream_get_position
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:188
DLL_EXPORT
#define DLL_EXPORT
Definition: dsp.h:27
dsp_stream_t::dims
int dims
Number of dimensions of the buffers.
Definition: dsp.h:180
dsp_stream_t::ROI
dsp_region * ROI
Regions of interest for each dimension.
Definition: dsp.h:218
dsp_region_t
Delimits a region in a single dimension of a buffer.
Definition: dsp.h:144
dsp_region_t::len
int len
Length of the region.
Definition: dsp.h:149
dsp_align_info_t::factor
double factor
Scaling factor.
Definition: dsp.h:123
dsp_buffer_1div
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:150
dsp_stream_add_dim
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:111
dsp_stream_del_dim
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:126
dsp_fourier_dft_phase
DLL_EXPORT void dsp_fourier_dft_phase(dsp_stream_p stream)
Perform a discrete Fourier Transform of a dsp_stream and obtain the complex phases.
dsp_t
#define dsp_t
Definition: dsp.h:57
dsp_stream_t::parent
struct dsp_stream_t * parent
The stream this one is child of.
Definition: dsp.h:188
dsp_stream_t::red
int red
Red pixel (Bayer)
Definition: dsp.h:208
dsp_file_read_fits
DLL_EXPORT dsp_stream_p * dsp_file_read_fits(char *filename, int *channels, int stretch)
Read a FITS file and fill a dsp_stream_p with its content.
Definition: file.c:26
dsp_stream_del_star
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:173
dsp_stream_t::child_count
int child_count
Children streams count.
Definition: dsp.h:192
dsp_region
struct dsp_region_t dsp_region
Delimits a region in a single dimension of a buffer.
dsp_buffer_mul1
DLL_EXPORT void dsp_buffer_mul1(dsp_stream_p stream, double val)
Multiply elements of the input stream to a value.
Definition: buffer.c:170
dsp_stream_t::children
struct dsp_stream_t ** children
Children streams of the current one.
Definition: dsp.h:190
Aux::buffer
std::vector< uint8_t > buffer
Definition: celestronauxpacket.h:38
dsp_stream_t::buf
dsp_t * buf
buffer
Definition: dsp.h:184
dsp_stream_t::target
double * target
Target coordinates.
Definition: dsp.h:196
dsp_stream_add_star
DLL_EXPORT void dsp_stream_add_star(dsp_stream_p stream, dsp_star star)
Add a star into the stream struct.
Definition: stream.c:164