00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef MULTISPOT5_H
00021 #define MULTISPOT5_H
00022 #include <vector>
00023 #include <string>
00024 #include <fstream>
00025 #include <iostream>
00026 #include <tr1/memory>
00027 #include <cvd/image.h>
00028 #include <cvd/byte.h>
00029 #include <TooN/TooN.h>
00030 #include <TooN/so2.h>
00031
00032 #include "utility.h"
00033 #include "mt19937.h"
00034
00035
00036
00037
00038
00039 class FitSpotsGraphics
00040 {
00041 public:
00042
00043
00044 virtual void init(CVD::ImageRef size)=0;
00045
00046
00047
00048
00049
00050
00051
00052 virtual void draw_krap(const std::vector<TooN::Vector<4> >& spots, const CVD::Image<CVD::byte>& im, const BBox& box, int N, TooN::Vector<4> s = TooN::Ones * 1e99)=0;
00053
00054
00055 virtual void swap()=0;
00056
00057
00058
00059
00060
00061
00062
00063 virtual void draw_pixels(const std::vector<CVD::ImageRef>& pix, float r, float g, float b, float a=1)=0;
00064
00065
00066
00067 virtual void draw_bbox(const BBox& bbox)=0;
00068
00069
00070
00071
00072 virtual void glDrawCross(const TooN::Vector<2>& p, int size=3)=0;
00073
00074
00075 virtual ~FitSpotsGraphics();
00076 };
00077
00078 std::auto_ptr<FitSpotsGraphics> null_graphics();
00079
00080
00081 struct LogFileParseError
00082 {
00083
00084 LogFileParseError(const std::string &s)
00085 :what(s)
00086 {}
00087
00088
00089 std::string what;
00090 };
00091
00092 void fit_spots_historic(const CVD::BasicImage<double>& log_ratios, const std::vector<CVD::Image<float> >& ims, std::vector<CVD::ImageRef> pixels, FitSpotsGraphics& g);
00093
00094
00095
00096 struct StateParameters{
00097 std::tr1::shared_ptr<MT19937> rng;
00098 std::vector<TooN::Vector<4> > spots;
00099 int pass;
00100 int iteration;
00101 std::vector<CVD::ImageRef> pixels;
00102 };
00103
00104 StateParameters generate_state_parameters_ye_olde(const CVD::BasicImage<double>& log_ratios, const std::vector<CVD::Image<float> >& ims, std::vector<CVD::ImageRef> pixels);
00105
00106 void fit_spots_new(const std::vector<CVD::Image<float> >& ims, StateParameters& p, std::ofstream& save_spots, FitSpotsGraphics&);
00107
00108 StateParameters parse_log_file(std::istream& in);
00109 #endif