Alternaria
fit cylinders and ellipsoids to fungus
psf_model.h
Go to the documentation of this file.
00001 /*
00002  * This work is licensed under a Creative Commons 
00003  * Attribution-Noncommercial-Share Alike 3.0 United States License.
00004  * 
00005  *    http://creativecommons.org/licenses/by-nc-sa/3.0/us/
00006  * 
00007  * You are free:
00008  * 
00009  *    to Share - to copy, distribute, display, and perform the work
00010  *    to Remix - to make derivative works
00011  * 
00012  * Under the following conditions:
00013  * 
00014  *    Attribution. You must attribute the work in the manner specified by the
00015  *    author or licensor (but not in any way that suggests that they endorse you
00016  *    or your use of the work).
00017  * 
00018  *    Noncommercial. You may not use this work for commercial purposes.
00019  * 
00020  *    Share Alike. If you alter, transform, or build upon this work, you may
00021  *    distribute the resulting work only under the same or similar license to
00022  *    this one.
00023  * 
00024  * For any reuse or distribution, you must make clear to others the license
00025  * terms of this work. The best way to do this is by including this header.
00026  * 
00027  * Any of the above conditions can be waived if you get permission from the
00028  * copyright holder.
00029  * 
00030  * Apart from the remix rights granted under this license, nothing in this
00031  * license impairs or restricts the author's moral rights.
00032  */
00033 
00034 
00046 #ifndef PSF_MODEL_H
00047 #define PSF_MODEL_H
00048 
00049 
00050 #include <config.h>
00051 
00052 #include <iostream>
00053 
00054 #include <inttypes.h>
00055 
00056 #include <jwsc/matblock/matblock.h>
00057 
00058 #include <jwsc++/base/exception.h>
00059 
00060 #include "density.h"
00061 #include "printable.h"
00062 #include "imaging_model.h"
00063 
00064 
00074 class PSF_padding
00075 {
00076     public:
00077 
00079         PSF_padding();
00080 
00081 
00083         virtual ~PSF_padding() { }
00084 
00085 
00092         uint32_t conv;
00093 
00100         uint32_t fft;
00101 };
00102 
00103 
00109 class PSF
00110 {
00111     public:
00112 
00114         PSF(const PSF_padding* padding);
00115 
00116 
00118         virtual ~PSF();
00119 
00120 
00122         virtual PSF& operator= (const PSF& psf);
00123 
00124 
00126         const PSF_padding* get_padding() const { return padding; }
00127 
00128 
00130         const jwsc::Matblock_f* get_h() const { return h; }
00131 
00132 
00134         virtual void update_h(const Imaging_model* imaging) = 0;
00135 
00136 
00141         void write_h(const char* fname_fmt) const 
00142             throw (jwscxx::base::IO_error);
00143 
00144 
00145     protected:
00146 
00148         const PSF_padding* padding;
00149 
00151         jwsc::Matblock_f* h;
00152 };
00153 
00154 
00162 class PSF_model_density
00163 {
00164     public:
00165 
00170         PSF_model_density() throw (jwscxx::base::Arg_error);
00171 
00172 
00174         virtual ~PSF_model_density() { }
00175 
00176 
00178         PSF_model_density* clone() const;
00179 
00180 
00182         const Density::Gaussian_params& get_alpha() const { return alpha; }
00183 
00184 
00186         const Density::Gaussian_params& get_beta() const { return beta; }
00187 
00188 
00190         const Density::Gaussian_params& get_gamma() const { return gamma; }
00191 
00192 
00194         void set_alpha(float mu, float sigma, float min, float max) 
00195             throw (jwscxx::base::Arg_error);
00196 
00197 
00199         void set_beta(float mu, float sigma, float min, float max) 
00200             throw (jwscxx::base::Arg_error);
00201 
00202 
00204         void set_gamma(float mu, float sigma, float min, float max) 
00205             throw (jwscxx::base::Arg_error);
00206 
00207 
00209         float sample_alpha() const;
00210 
00211 
00213         float sample_beta() const;
00214 
00215 
00217         float sample_gamma() const;
00218 
00219 
00221         class PSF_model* sample
00222         (
00223             const PSF_padding*   padding, 
00224             const Imaging_model* imaging
00225         ) 
00226         const;
00227 
00228 
00229     protected:
00230 
00232         Density::Gaussian_params  alpha;
00233 
00235         Density::Gaussian_params  beta;
00236 
00238         Density::Gaussian_params  gamma;
00239 };
00240 
00241 
00263 class PSF_model : public PSF, Printable
00264 {
00265     public:
00266 
00268         PSF_model
00269         (
00270             float                    alpha,
00271             float                    beta,
00272             float                    gamma,
00273             const PSF_padding*       padding,
00274             const PSF_model_density* density,
00275             const Imaging_model*     imaging
00276         )
00277         throw (jwscxx::base::Arg_error);
00278 
00279 
00281         PSF_model(const PSF_model& model);
00282 
00283 
00285         PSF_model
00286         (
00287             const char*              fname, 
00288             const PSF_padding*       padding,
00289             const PSF_model_density* density,
00290             const Imaging_model*     imaging
00291         )
00292         throw (jwscxx::base::IO_error, jwscxx::base::Arg_error);
00293 
00294 
00296         virtual ~PSF_model() { }
00297 
00298 
00300         PSF_model& operator= (const PSF_model& psf);
00301 
00302 
00304         PSF_model* clone();
00305 
00306 
00308         float get_alpha() const { return alpha; }
00309 
00310 
00312         float get_beta() const { return beta; }
00313 
00314 
00316         float get_gamma() const { return gamma; }
00317 
00318 
00320         double get_log_prob() const { return log_prob; }
00321 
00322 
00324         const PSF_model_density* get_density() const { return density; }
00325 
00326 
00328         void set
00329         (
00330             float                alpha, 
00331             float                beta, 
00332             float                gamma, 
00333             const Imaging_model* imaging
00334         ) 
00335         throw (jwscxx::base::Arg_error);
00336 
00337 
00339         void set_alpha(float alpha, const Imaging_model* imaging) 
00340             throw (jwscxx::base::Arg_error);
00341 
00342 
00344         void set_beta(float beta, const Imaging_model* imaging) 
00345             throw (jwscxx::base::Arg_error);
00346 
00347 
00349         void set_gamma(float gamma, const Imaging_model* imaging) 
00350             throw (jwscxx::base::Arg_error);
00351 
00352 
00354         void print(std::ostream& out=std::cout) const;
00355 
00356 
00358         void print(const char* fname) const throw (jwscxx::base::IO_error);
00359 
00360 
00362         void update_h(const Imaging_model* imaging);
00363 
00364 
00365     protected:
00366 
00368         void update_log_prob();
00369 
00373         void check_alpha() const throw (jwscxx::base::Arg_error);
00374 
00378         void check_beta() const throw (jwscxx::base::Arg_error);
00379 
00380 
00384         void check_gamma() const throw (jwscxx::base::Arg_error);
00385 
00386 
00387     protected:
00388 
00395         float alpha;
00396 
00403         float beta;
00404 
00410         float gamma;
00411 
00413         double log_prob;
00414 
00416         const PSF_model_density* density;
00417 };
00418 
00419 
00427 class PSF_delta_model : public PSF
00428 {
00429     public:
00430 
00432         PSF_delta_model
00433         (
00434             const PSF_padding*   padding, 
00435             const Imaging_model* imaging
00436         );
00437 
00438 
00440         virtual ~PSF_delta_model() { }
00441 
00442 
00444         void update_h(const Imaging_model* imaging);
00445 };
00446 
00447 
00456 class PSF_gauss_model : public PSF
00457 {
00458     public:
00459 
00461         PSF_gauss_model
00462         (
00463             float                sigma, 
00464             const PSF_padding*   padding, 
00465             const Imaging_model* imaging
00466         )
00467         throw (jwscxx::base::Arg_error);
00468 
00469 
00471         virtual ~PSF_gauss_model() { }
00472 
00473 
00475         void update_h(const Imaging_model* imaging);
00476 
00477 
00479         PSF_gauss_model& operator= (const PSF_gauss_model& psf);
00480 
00481 
00482     protected:
00483 
00485         float sigma;
00486 };
00487 
00488 
00489 #endif