Spacecraft Control Framework 1.0
Spacecraft Control Library
sc_optics.h
Go to the documentation of this file.
1/*
2 * sc_optics.h
3 *
4 * Programmer(s): Michael Paluszek
5 *
6 * Copyright (c) 2009, Princeton Satellite Systems. All rights reserved.
7 *
8 */
9
16#ifndef SC_OPTICS
17#define SC_OPTICS
18
19#ifdef AS_OS_WINDOWS
20#include "matrixlib.h"
21#else
22#include <MatrixLib/MatrixLib.h>
23#endif
24#include <vector>
25#include <stdint.h>
26using namespace std;
27
31typedef struct camera_data_s {
32 ml_matrix o;
33 ml_matrix s;
34 ml_matrix f;
35 double k1;
36 double k2;
37 double alpha;
38 ml_matrix R;
39 ml_matrix T;
41
42
44typedef struct psf_data_s {
45 ml_matrix r;
46 ml_matrix i;
47 int n;
48 int m;
49 double x_pixel;
50 double y_pixel;
52
54typedef struct gaussian_psf_s : psf_data_t {
55 double sigma;
57
59typedef struct airy_psf_s : psf_data_t {
60 double aperture;
61 double wavelength;
62 double f_length;
64
67 double defocus;
69
70
71
73double effective_focal_length( ml_matrix distance, ml_matrix focal_length );
75double diffraction_limit( double lambda, double aperture );
77ml_matrix angle_of_view( double focal_length, ml_matrix d );
79double angle_of_view( double focal_length, double d );
81ml_matrix angle_of_view( ml_matrix focal_length, double d );
83double focal_length_from_angle_of_view( double alpha, double d );
85ml_matrix separation_angles( ml_matrix u );
87ml_matrix pix_to_u( ml_matrix p, double f );
89ml_matrix u_to_pix( const ml_matrix& r, double f, double row = 0, double col = 0 );
91double laser_beam_radius( double d, double lambda, double z );
93double laser_power( double d, double lambda, double z, double power );
95camera_data_t camera_calibration( const ml_matrix& pD, const ml_matrix& pW );
97ml_matrix calibration_cube( double w, double r, int n );
99ml_matrix camera_calibration_model( camera_data_t d, const ml_matrix& pW, double f );
101ml_matrix imager_psf( ml_matrix PSF( const ml_matrix& x, const ml_matrix& y, void* context), psf_data_t* d );
103void imager_psf_uint16( ml_matrix PSF( const ml_matrix& x, const ml_matrix& y, void* context), psf_data_t* d, uint16_t* frame );
105int any_less_than( const ml_matrix& x, double d );
107ml_matrix rhs_gaussian_psf( const ml_matrix& x, const ml_matrix& y, void* context );
109ml_matrix rhs_airy_psf(const ml_matrix& x,const ml_matrix& y,void* context);
111ml_matrix rhs_airy_defocused_psf(const ml_matrix& x,const ml_matrix& y,void* context);
113ml_matrix rand_pn(double f, int n, int m );
115ml_matrix fit_PSF_to_data(const ml_matrix& r0, const ml_matrix& intensity, const ml_matrix& pixels, int nUse, int mUse);
117double cost_psf(const ml_matrix& x, void* context);
119
120
124{
125
126 public:
128 ml_matrix pixels;
131
132 ImagePSF();
133 ImagePSF(ml_matrix pixels);
134 static double rhs_fit_psf(double[]);
135};
136
137
138#endif
Helper class for matching PSFs to images.
Definition: sc_optics.h:124
ml_matrix pixels
Image pixel values.
Definition: sc_optics.h:128
psf_data_t * psf_data
Data needed for PSF.
Definition: sc_optics.h:130
double laser_beam_radius(double d, double lambda, double z)
Laser beam radius.
Definition: sc_optics.cc:191
ml_matrix calibration_cube(double w, double r, int n)
Camera cube.
Definition: sc_optics.cc:373
double focal_length_from_angle_of_view(double alpha, double d)
Focal length from angle of view.
Definition: sc_optics.cc:103
int any_less_than(const ml_matrix &x, double d)
Find if any value of x is less than d.
Definition: sc_optics.cc:536
airy_psf_s airy_psf_t
Structure for implementing an Airy psf.
camera_data_t camera_calibration(const ml_matrix &pD, const ml_matrix &pW)
Camera calibration.
Definition: sc_optics.cc:265
void imager_psf_uint16(ml_matrix PSF(const ml_matrix &x, const ml_matrix &y, void *context), psf_data_t *d, uint16_t *frame)
Imager with point spread function return a uint16_t array.
Definition: sc_optics.cc:436
double diffraction_limit(double lambda, double aperture)
Diffraction resolution limit.
Definition: sc_optics.cc:49
double cost_psf(const ml_matrix &x, void *context)
PSF cost function.
Definition: sc_optics.cc:828
ml_matrix pix_to_u(ml_matrix p, double f)
Converts a pixel map to a unit vector assuming a pinhole camera model.
Definition: sc_optics.cc:170
double effective_focal_length(ml_matrix distance, ml_matrix focal_length)
Computes effective focal length.
Definition: sc_optics.cc:26
double laser_power(double d, double lambda, double z, double power)
Laser power.
Definition: sc_optics.cc:218
ml_matrix rand_pn(double f, int n, int m)
Poisson random matrix.
Definition: sc_optics.cc:713
ml_matrix rhs_gaussian_psf(const ml_matrix &x, const ml_matrix &y, void *context)
Gaussian point spread function.
Definition: sc_optics.cc:559
struct psf_data_s psf_data_t
Structure for storing point spread function data.
gaussian_psf_s gaussian_psf_t
Structure for implementing a Gaussian psf.
ml_matrix imager_psf(ml_matrix PSF(const ml_matrix &x, const ml_matrix &y, void *context), psf_data_t *d)
Imager with point spread functions.
Definition: sc_optics.cc:486
ml_matrix fit_PSF_to_data(const ml_matrix &r0, const ml_matrix &intensity, const ml_matrix &pixels, int nUse, int mUse)
Fit PSF to coarse centroid data using numerical optimization.
Definition: sc_optics.cc:729
ml_matrix angle_of_view(double focal_length, ml_matrix d)
Angle of view from focal length with a 2D input.
Definition: sc_optics.cc:62
ml_matrix separation_angles(ml_matrix u)
Separation angles and pairs.
Definition: sc_optics.cc:108
ml_matrix camera_calibration_model(camera_data_t d, const ml_matrix &pW, double f)
Camera model.
Definition: sc_optics.cc:234
ml_matrix u_to_pix(const ml_matrix &r, double f, double row=0, double col=0)
Converts a unit vector to a pixel map assuming a pinhole camera model.
Definition: sc_optics.cc:144
airydefocused_psf_s airydefocused_psf_t
Structure for implementing a defocused Airy psf.
ml_matrix rhs_airy_psf(const ml_matrix &x, const ml_matrix &y, void *context)
Airy point spread function.
Definition: sc_optics.cc:670
ml_matrix rhs_airy_defocused_psf(const ml_matrix &x, const ml_matrix &y, void *context)
Defocused Airy point spread function.
Definition: sc_optics.cc:622
Structure for implementing an Airy psf.
Definition: sc_optics.h:59
double aperture
Aperture (mm)
Definition: sc_optics.h:60
double f_length
Focal length (mm), distance from aperture to image plane.
Definition: sc_optics.h:62
double wavelength
Wavelength (nm)
Definition: sc_optics.h:61
Structure for implementing a defocused Airy psf.
Definition: sc_optics.h:66
double defocus
Defocus parameter.
Definition: sc_optics.h:67
Definition: sc_optics.h:31
ml_matrix R
Rotation matrix (3,3)
Definition: sc_optics.h:38
double k1
Radial error r^2 coeff.
Definition: sc_optics.h:35
ml_matrix s
[x,y] pixel dimensions (1,2)
Definition: sc_optics.h:33
double alpha
Focal length ratio fX/fY.
Definition: sc_optics.h:37
ml_matrix f
Focal length.
Definition: sc_optics.h:34
ml_matrix o
[x,y] origin (1,2)
Definition: sc_optics.h:32
ml_matrix T
Offset (3,1)
Definition: sc_optics.h:39
double k2
Radial error r^4 coeff.
Definition: sc_optics.h:36
Structure for implementing a Gaussian psf.
Definition: sc_optics.h:54
double sigma
Standard deviation.
Definition: sc_optics.h:55
Structure for storing point spread function data.
Definition: sc_optics.h:44
int n
Number of rows in the pixel array.
Definition: sc_optics.h:47
int m
Number of columns in the pixel array.
Definition: sc_optics.h:48
ml_matrix i
Intensity.
Definition: sc_optics.h:46
double x_pixel
X Width of a pixel (microns)
Definition: sc_optics.h:49
ml_matrix r
[x;y] origin of peaks
Definition: sc_optics.h:45
double y_pixel
Y Width of a pixel (microns)
Definition: sc_optics.h:50