00001 #ifndef __FIELD_H__
00002 #define __FIELD_H__
00003
00004 #include <stdint.h>
00005 #include "processor.h"
00006 #include "image.h"
00007
00008 namespace spectral {
00009
00010 struct weights
00011 {
00012 int index[4];
00013 float weight[4];
00014 };
00015
00016 class Field : public Processor
00017 {
00018 public:
00019 Field();
00020 virtual ~Field();
00021
00022 protected:
00023
00024
00025
00026 virtual uint32_t GetInterface(
00027 std::list<std::pair<uint32_t, uint32_t> > &mandatory,
00028 std::list<std::pair<uint32_t, uint32_t> > &optional) const;
00029
00030
00031 virtual bool SetImage(uint32_t type, const Image *img);
00032
00033
00034 virtual void SetParameters(const Parameters *);
00035
00036
00037 virtual Image *Process(void) = 0;
00038
00039
00040 virtual void ClearImage(uint32_t type);
00041
00042 protected:
00043
00044
00045 virtual void GetParameters(Parameters *) const;
00046
00047 protected:
00048 spectral::image<float> *MakeField(void);
00049
00050 void GetWeight(int32_t width, int32_t height, float x, float y, struct weights &);
00051
00052 void BuildStreamline(float x, float y,
00053 spectral::image<float> *field,
00054 std::list<std::pair<float, float> > &result);
00055
00056 void FollowStreamline(std::list<std::pair<float, float> >&line,
00057 spectral::Image *src,
00058 spectral::Image *result,
00059 spectral::image<float> *hits);
00060
00061 void DarkStreamline(std::list<std::pair<float, float> >&line,
00062 spectral::Image *result,
00063 spectral::image<float> *hits);
00064
00065 bool GetFieldDirection(spectral::image<float> *field,
00066 float *pos, float *dir);
00067 bool GetColour(const spectral::Image *, float x, float y, float *colour);
00068
00069 bool SplatColour(float x, float y, float *colour,
00070 spectral::Image *, spectral::image<float> *, float weight = 1);
00071
00072 const spectral::Image *m_picture;
00073 const spectral::Image *m_field;
00074
00075 float m_weight;
00076 int m_size;
00077 bool m_fine;
00078 bool m_contour;
00079 int32_t m_streamline_length;
00080 };
00081
00082 }
00083
00084 #endif