Alternaria
fit cylinders and ellipsoids to fungus
imaging_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 
00047 #ifndef IMAGING_MODEL_H
00048 #define IMAGING_MODEL_H
00049 
00050 
00051 #include <config.h>
00052 
00053 #include <iostream>
00054 
00055 #include <inttypes.h>
00056 
00057 #include <jwsc++/base/exception.h>
00058 
00059 #include "density.h"
00060 #include "printable.h"
00061 
00062 
00068 class Imaging_window
00069 {
00070     public:
00071 
00075         Imaging_window() throw (jwscxx::base::Arg_error);
00076 
00077 
00079         virtual ~Imaging_window() { }
00080 
00081 
00083         uint32_t get_col() const { return col; }
00084 
00085 
00087         uint32_t get_row() const { return row; }
00088 
00089 
00091         uint32_t get_img() const { return img; }
00092 
00093 
00095         uint32_t get_num_cols() const { return num_cols; }
00096 
00097 
00099         uint32_t get_num_rows() const { return num_rows; }
00100 
00101 
00103         uint32_t get_num_imgs() const { return num_imgs; }
00104 
00105 
00107         void set
00108         (
00109             uint32_t col, 
00110             uint32_t row, 
00111             uint32_t img, 
00112             uint32_t num_cols,
00113             uint32_t num_rows,
00114             uint32_t num_imgs
00115         )
00116         throw (jwscxx::base::Arg_error);
00117 
00118 
00119     protected:
00120 
00122         uint32_t col;
00123 
00125         uint32_t row;
00126 
00128         uint32_t img;
00129 
00131         uint32_t num_cols;
00132 
00134         uint32_t num_rows;
00135 
00137         uint32_t num_imgs;
00138 
00139 
00141     friend std::ostream& operator<<(std::ostream&, const Imaging_window&);
00142 
00143 
00145     friend std::istream& operator>>(std::istream&, Imaging_window&);
00146 };
00147 
00148 
00154 class Imaging_scale
00155 {
00156     public:
00157 
00161         Imaging_scale() throw (jwscxx::base::Arg_error);
00162 
00163 
00165         virtual ~Imaging_scale() { }
00166 
00167 
00169         float get_x() const { return x; }
00170 
00171 
00173         float get_y() const { return y; }
00174 
00175 
00177         float get_z() const { return z; }
00178 
00179 
00181         void set(float x, float y, float z) throw (jwscxx::base::Arg_error);
00182 
00183 
00184     protected:
00185 
00190         float x;
00191 
00196         float y;
00197 
00201         float z;
00202 
00203 
00205     friend std::ostream& operator<<(std::ostream&, const Imaging_scale&);
00206 
00207 
00209     friend std::istream& operator>>(std::istream&, Imaging_scale&);
00210 };
00211 
00212 
00218 class Imaging_model_density
00219 {
00220     public:
00221 
00226         Imaging_model_density() throw (jwscxx::base::Arg_error);
00227 
00228 
00230         virtual ~Imaging_model_density() { }
00231 
00232 
00234         Imaging_model_density* clone() const;
00235 
00236 
00238         const Density::Gaussian_params& get_bg() const { return bg; }
00239 
00240 
00242         const Density::Uniform_params& get_c_2() const { return c_2; }
00243 
00244 
00246         void set_bg(float mu, float sigma, float min, float max) 
00247             throw (jwscxx::base::Arg_error);
00248 
00249 
00251         void set_c_2(float min, float max) throw (jwscxx::base::Arg_error);
00252 
00253 
00255         float sample_bg() const;
00256 
00257 
00259         float sample_c_2() const;
00260 
00261 
00263         class Imaging_model* sample
00264         (
00265             const Imaging_window* window,
00266             const Imaging_scale*  scale
00267         )
00268         const;
00269 
00270 
00271     protected:
00272 
00274         Density::Gaussian_params  bg;
00275 
00277         Density::Uniform_params  c_2;
00278 };
00279 
00280 
00286 class Imaging_model : public Printable
00287 {
00288     public:
00289 
00291         Imaging_model
00292         (
00293             float                        bg,
00294             float                        c_2,
00295             const Imaging_window*        window,
00296             const Imaging_scale*         scale,
00297             const Imaging_model_density* density
00298         )
00299         throw (jwscxx::base::Arg_error);
00300 
00301 
00303         Imaging_model(const Imaging_model& model);
00304 
00305 
00307         Imaging_model
00308         (
00309             const char* fname, 
00310             const Imaging_window*        window,
00311             const Imaging_scale*         scale,
00312             const Imaging_model_density* density
00313         )
00314         throw (jwscxx::base::IO_error, jwscxx::base::Arg_error);
00315 
00316 
00318         virtual ~Imaging_model() { }
00319 
00320 
00322         Imaging_model* clone();
00323 
00324 
00326         const Imaging_window* get_window() const { return window; }
00327 
00328 
00330         const Imaging_scale* get_scale() const { return scale; }
00331 
00332 
00334         float get_bg() const { return bg; }
00335 
00336 
00338         float get_c_2() const { return c_2; }
00339 
00340 
00342         double get_log_prob() const { return log_prob; }
00343 
00344 
00346         const Imaging_model_density* get_density() const { return density; }
00347 
00348 
00350         void set_bg(float bg) throw (jwscxx::base::Arg_error);
00351 
00352 
00354         void set_c_2(float c_2) throw (jwscxx::base::Arg_error);
00355 
00356 
00358         void print(std::ostream& out=std::cout) const;
00359 
00360 
00362         void print(const char* fname) const throw (jwscxx::base::IO_error);
00363 
00364 
00365     protected:
00366 
00368         void update_log_prob();
00369 
00374         void check_bg() const throw (jwscxx::base::Arg_error);
00375 
00380         void check_c_2() const throw (jwscxx::base::Arg_error);
00381 
00382 
00383     protected:
00384 
00386         const Imaging_window* window;
00387 
00392         const Imaging_scale* scale;
00393 
00399         float bg;
00400 
00410         float c_2;
00411 
00413         double log_prob;
00414 
00416         const Imaging_model_density* density;
00417 };
00418 
00419 
00420 #endif