Instrument Neutral Distributed Interface INDI 2.2.5
dsp.h File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>
#include <sys/types.h>
#include <time.h>
#include <assert.h>
#include <pthread.h>
#include <fits_extensions.h>

Go to the source code of this file.

Classes

struct  dsp_point_t
 Indicates a dot or line inside a dsp_stream. More...
struct  dsp_offset_t
 Indicates an offset. More...
struct  dsp_star_t
 A star or object contained into a buffer. More...
struct  dsp_triangle_t
 A star or object contained into a buffer. More...
struct  dsp_align_info_t
 Alignment information needed. More...
union  dsp_complex
 Complex number array struct, used in Fourier Transform functions. More...
struct  dsp_region_t
 Delimits a region in a single dimension of a buffer. More...
union  dsp_location_t
 The location type. More...
struct  dsp_stream_t
 Contains a set of information and data relative to a buffer and how to use it. More...

Macros

#define DLL_EXPORT   extern
#define __bswap_16(a)
#define __bswap_32(a)
#define __bswap_64(a)
#define M_PI   3.14159265358979323846
#define DSP_MAX_STARS   200
#define dsp_t_max   255
#define dsp_t_min   -dsp_t_max
#define DSP_NAME_SIZE   128
#define DSP_DEBUG
#define DSP_DEBUG_INFO   0
#define DSP_DEBUG_ERROR   1
#define DSP_DEBUG_WARNING   2
#define DSP_DEBUG_DEBUG   3
#define pdbg(x, ...)
#define pinfo(...)
#define perr(...)
#define pwarn(...)
#define pgarb(...)
#define pfunc   pgarb("%s\n", __func__)
#define start_gettime
#define end_gettime
#define Min(a, b)
 if min() is not present you can use this one
#define Max(a, b)
 if max() is not present you can use this one
#define Log(a, b)
 Logarithm of a with arbitrary base b.
#define DSP_ALIGN_TRANSLATED   1
 The stream is translated by the reference.
#define DSP_ALIGN_SCALED   2
 The stream is scaled by the reference.
#define DSP_ALIGN_ROTATED   4
 The stream is rotated by the reference.
#define DSP_ALIGN_NO_MATCH   8
 No matches were found during comparison.
#define dsp_stats_min(buf, len)
 Gets the minimum value of the input stream.
#define dsp_stats_max(buf, len)
 Gets the maximum value of the input stream.
#define dsp_stats_mid(buf, len)
 Gets the middle value of the input stream.
#define dsp_stats_minimum_index(buf, len)
 Gets minimum value's position into the buffer.
#define dsp_stats_maximum_index(buf, len)
 Gets maximum value's position into the buffer.
#define dsp_stats_mean(buf, len)
 A mean calculator.
#define dsp_stats_stddev(buf, len)
 Standard deviation of the inut stream.
#define dsp_stats_val_count(buf, len, val)
 Counts value occurrences into stream.
#define dsp_stats_val_sum(buf, len)
 Cumulative sum of all the values on the stream.
#define dsp_stats_range_count(buf, len, lo, hi)
 Counts value ranging occurrences into stream.
#define dsp_stats_compare(in1, in2, len)
 Compare two buffers.
#define dsp_buffer_stretch(buf, len, _mn, _mx)
 Stretch minimum and maximum values of the input stream.
#define dsp_buffer_set(buf, len, _val)
 Fill the buffer with the passed value.
#define dsp_buffer_normalize(buf, len, mn, mx)
 Normalize the input stream to the minimum and maximum values.
#define dsp_buffer_reverse(buf, len)
 Reverse the order of the buffer elements.
#define dsp_buffer_swap(in, len)
 Change the in buffer elements endianness.
#define dsp_buffer_copy(in, out, len)
 Fill the output buffer with the values of the elements of the input stream by casting them to the output buffer element type.
#define dsp_buffer_copy_stepping(in, out, inlen, outlen, instep, outstep)
 Fill the output buffer with the values of the elements of the input stream by casting them to the output buffer element type.

Typedefs

typedef double dsp_t
typedef double complex_t[2]
typedef struct dsp_point_t dsp_point
 Indicates a dot or line inside a dsp_stream.
typedef struct dsp_offset_t dsp_offset
 Indicates an offset.
typedef struct dsp_star_t dsp_star
 A star or object contained into a buffer.
typedef struct dsp_triangle_t dsp_triangle
 A star or object contained into a buffer.
typedef struct dsp_align_info_t dsp_align_info
 Alignment information needed.
typedef struct dsp_region_t dsp_region
 Delimits a region in a single dimension of a buffer.
typedef union dsp_location_t dsp_location
 The location type.
typedef void *(* dsp_func_t) (void *,...)
 Multi-dimensional processing delegate function.
typedef struct dsp_stream_t dsp_stream
 Contains a set of information and data relative to a buffer and how to use it.
typedef struct dsp_stream_t * dsp_stream_p

Functions

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 int dsp_get_debug_level ()
 get the debug level
DLL_EXPORT void dsp_set_app_name (char *name)
 set the application name
DLL_EXPORT char * dsp_get_app_name ()
 get the application name
DLL_EXPORT void dsp_set_stdout (FILE *f)
 set the output log streeam
DLL_EXPORT void dsp_set_stderr (FILE *f)
 set the error log streeam
DLL_EXPORT void dsp_print (int x, char *str)
 log a message to the error or output streams
DLL_EXPORT void dsp_fourier_dft (dsp_stream_p stream, int exp)
 Perform a discrete Fourier Transform of a dsp_stream.
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_2dsp (dsp_stream_p stream)
 Fill the magnitude and phase buffers with the current data in stream->dft.
DLL_EXPORT void dsp_fourier_2complex_t (dsp_stream_p stream)
 Obtain the complex fourier transform 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 double * dsp_fourier_complex_array_get_magnitude (dsp_complex in, int len)
 Obtain a complex number's array magnitudes.
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_filter_squarelaw (dsp_stream_p stream)
 A square law filter.
DLL_EXPORT void dsp_filter_lowpass (dsp_stream_p stream, double frequency)
 A low pass filter.
DLL_EXPORT void dsp_filter_highpass (dsp_stream_p stream, double frequency)
 A high pass filter.
DLL_EXPORT void dsp_filter_bandpass (dsp_stream_p stream, double LowFrequency, double HighFrequency)
 A band pass filter.
DLL_EXPORT void dsp_filter_bandreject (dsp_stream_p stream, double LowFrequency, double HighFrequency)
 A band reject filter.
DLL_EXPORT void dsp_convolution_convolution (dsp_stream_p stream, dsp_stream_p matrix)
 A cross-convolution processor.
DLL_EXPORT void dsp_convolution_correlation (dsp_stream_p stream, dsp_stream_p matrix)
 A cross-correlation processor.
DLL_EXPORT double * dsp_stats_histogram (dsp_stream_p stream, int size)
 Histogram of the inut stream.
DLL_EXPORT void dsp_buffer_shift (dsp_stream_p stream)
 Shift a stream on each dimension.
DLL_EXPORT void dsp_buffer_removemean (dsp_stream_p stream)
 Subtract mean from stream.
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_min (dsp_stream_p stream, dsp_t *in, int len)
 Sum elements of one stream to another's.
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_sum (dsp_stream_p stream, dsp_t *in, int len)
 Sum elements of one stream to another's.
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_mul (dsp_stream_p stream, dsp_t *in, int len)
 Multiply elements of one stream to another's.
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_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_sub1 (dsp_stream_p stream, dsp_t val)
 Subtract a value from elements of the input 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_sum1 (dsp_stream_p stream, dsp_t val)
 Sum elements of the input stream to a value.
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_1div (dsp_stream_p stream, double val)
 Divide a value to each element 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_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_median (dsp_stream_p stream, int size, int median)
 Median elements of the input stream.
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_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_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_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 dsp_t * dsp_stream_get_buffer (dsp_stream_p stream)
 Return the buffer of the stream passed as argument.
DLL_EXPORT void dsp_stream_free_buffer (dsp_stream_p stream)
 Free the buffer of the DSP Stream passed as argument.
DLL_EXPORT dsp_stream_p dsp_stream_new (void)
 Allocate a new DSP stream type.
DLL_EXPORT void dsp_stream_free (dsp_stream_p stream)
 Free the DSP stream passed as argument.
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_child (dsp_stream_p stream, dsp_stream_p child)
 Add a child to the DSP Stream passed as argument.
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_del_star (dsp_stream_p stream, int n)
 Remove the star with index n to a DSP stream.
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_del_triangle (dsp_stream_p stream, int index)
 Remove the triangle with index n to a DSP stream.
DLL_EXPORT void dsp_stream_calc_triangles (dsp_stream_p stream)
 Calculate the triangles in the stream struct.
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 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_set_dim (dsp_stream_p stream, int dim, int size)
 Set a dimension size to a DSP stream.
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 int dsp_stream_set_position (dsp_stream_p stream, int *pos)
 Obtain the position the DSP stream by parsing multidimensional indexes.
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_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_crop (dsp_stream_p stream)
 Crop the buffers of the stream passed as argument by reading the ROI field.
DLL_EXPORT void dsp_stream_rotate (dsp_stream_p stream)
 Rotate a stream around an axis and offset.
DLL_EXPORT void dsp_stream_sum (dsp_stream_p stream, dsp_stream_p in)
 Sum a stream with another.
DLL_EXPORT void dsp_stream_multiply (dsp_stream_p stream, dsp_stream_p in)
 Multiply a stream with another.
DLL_EXPORT void dsp_stream_subtract (dsp_stream_p stream, dsp_stream_p in)
 Subtract a stream to another.
DLL_EXPORT void dsp_stream_translate (dsp_stream_p stream)
 Translate a stream.
DLL_EXPORT void dsp_stream_scale (dsp_stream_p stream)
 Scale a stream.
DLL_EXPORT void dsp_stream_align (dsp_stream_p stream)
 Perform scale, translate and rotate transformations in-place.
DLL_EXPORT void dsp_signals_whitenoise (dsp_stream_p stream)
 Generate white noise.
DLL_EXPORT void dsp_signals_sinewave (dsp_stream_p stream, double samplefreq, double freq)
 Generate a sinusoidal wave.
DLL_EXPORT void dsp_signals_sawtoothwave (dsp_stream_p stream, double samplefreq, double freq)
 Generate a sawtooth wave.
DLL_EXPORT void dsp_signals_triwave (dsp_stream_p stream, double samplefreq, double freq)
 Generate a triangular 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_modulation_amplitude (dsp_stream_p stream, double samplefreq, double freq)
 Generate an amplitude modulated wave.
void dsp_recons_align (dsp_stream_p stream, dsp_stream_p matrix)
 Try to reconstruct a stream from sub-stream matrices.
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 (const char *filename, int bpp, dsp_stream_p stream)
 Write the dsp_stream_p into a FITS file,.
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_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 stream in this array and an additional grayscale at end will be added.
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 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_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 stream in this array and an additional grayscale at end will be added.
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_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 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_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 components.
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 components.
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 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_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_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.
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 dsp_triangle * dsp_align_calc_triangle (dsp_star *stars, int num_stars)
 Create a dsp_triangle struct.
DLL_EXPORT void dsp_align_free_triangle (dsp_triangle *triangle)
 Free a dsp_triangle struct pointer.
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.

Macro Definition Documentation

◆ __bswap_16

#define __bswap_16 ( a)
Value:
__builtin_bswap16(a)

Definition at line 37 of file dsp.h.

◆ __bswap_32

#define __bswap_32 ( a)
Value:
__builtin_bswap32(a)

Definition at line 38 of file dsp.h.

◆ __bswap_64

#define __bswap_64 ( a)
Value:
__builtin_bswap64(a)

Definition at line 39 of file dsp.h.

◆ DLL_EXPORT

#define DLL_EXPORT   extern

Definition at line 30 of file dsp.h.

◆ M_PI

#define M_PI   3.14159265358979323846

Definition at line 52 of file dsp.h.