2 * psychlops_figure_prototype.h
3 * Psychlops Standard Library (Universal)
5 * Last Modified 2005/10/05 by Kenchi HOSOKAWA
6 * (C) 2005 Kenchi HOSOKAWA, Kazushi MARUYA, Takao SATO
9 #ifndef HEADER_PSYCHLOPS_FIGURE_GABOR_PROTOTYPE
10 #define HEADER_PSYCHLOPS_FIGURE_GABOR_PROTOTYPE
14 #include "../../../psychlops_core.h"
20 // double gaussian(double sigma, double x);
23 namespace StimulusTemplate {
25 class Gabor : virtual public Figure {
28 Angle orientation, phase;
41 virtual Gabor& set(double freq, double sigma, double contrast = 0.5, double orient = 0.0, double phs=0.0) = 0;
42 virtual Gabor& set(Length freq, Length sigma, double contrast = 0.5, Angle orient = 0.0*degree, Angle phs=0.0*degree) = 0;
44 virtual Gabor& setContrast(double cont);
45 virtual Gabor& setWavelength(Length length);
46 virtual Gabor& setOrientation(Angle orient);
47 virtual Gabor& setPhase(Angle phs);
49 virtual Gabor& shift(const double x, const double y, const double z = 0.0) = 0;
50 virtual Gabor& centering(const double x, const double y, const double z = 0.0) = 0;
51 virtual Gabor& centering(const Point &po) = 0;
52 virtual Gabor& centering(const Drawable &target = *Drawable::prime) = 0;
53 virtual const Point getDatum() const;
55 virtual Gabor& draw(Drawable &target = *Drawable::prime) = 0;
56 virtual Gabor& draw(int x, int y, Drawable &target = *Drawable::prime) = 0;
63 int substructImages(Image &result, const Image &s1, const Image &s2, const double factor);
64 void drawImageCoordinateTuner(Image &img);
66 void drawGrating(Image &img, int width, int height, double wavelength, double contrast, double orientation, double phase);
67 void drawGaussian(Image &img, double sigma, double factor);
68 void drawGabor(Image &img, double sigma, double wavelength, double contrast, double orientation, double phase);
71 class GaborBase : public Rectangle {
76 double orientation, phase;
81 virtual GaborBase& setSigma(double sigma);
82 virtual GaborBase& setSigma(Length sigma);
83 virtual GaborBase& setWave(double wavelen, double cont = 0.5, double orient = 0.0, double phs=0.0);
84 virtual GaborBase& setWave(Length wavelen, double cont = 0.5, Angle orient = 0.0*degree, Angle phs=0.0*degree);
85 virtual GaborBase& cache(DrawableWithCache &target = *DrawableWithCache::prime) = 0;
86 virtual GaborBase& draw(Drawable &target = *DrawableWithCache::prime) = 0;
87 virtual void to(Image &dest, Canvas &media = *Display::the_canvas) = 0;
91 class ImageGabor : public GaborBase {
96 const bool operator <(Key rhs) const;
97 const bool operator >(Key rhs) const;
99 std::map<Key, Image*> cache_list;
104 virtual ImageGabor& cache(DrawableWithCache &target = *DrawableWithCache::prime);
105 virtual ImageGabor& draw(Drawable &target = *DrawableWithCache::prime);
106 virtual void to(Image &dest, Canvas &media = *Display::the_canvas);
111 class QuickGabor : public StimulusTemplate::Gabor {
113 friend class QuickGabor;
115 int referenced_count_;
121 void set(double sigma);
128 Instance& draw(int x, int y, Length frequency, Angle orientation, Angle phase, double consrast, Drawable &target);
130 static std::vector<Instance *> instance_;
132 int setInstance(double sigma);
137 // it is not good to call virtual function from constructors.
138 QuickGabor(double freq, double sigma, double contrast = 0.5, double orient = 0.0, double phs=0.0);
139 QuickGabor(Length freq, Length sigma, double contrast = 0.5, Angle orient = 0.0*degree, Angle phs=0.0*degree);
140 virtual ~QuickGabor();
141 virtual QuickGabor& set(double freq, double sigma, double contrast = 0.5, double orient = 0.0, double phs=0.0);
142 virtual QuickGabor& set(Length freq, Length sigma, double contrast = 0.5, Angle orient = 0.0*degree, Angle phs=0.0*degree);
144 virtual QuickGabor& setDatum(const Point &po);
145 virtual QuickGabor& shift(const double x, const double y, const double z = 0.0);
146 virtual QuickGabor& centering(const double x, const double y, const double z = 0.0);
147 virtual QuickGabor& centering(const Point &po);
148 virtual QuickGabor& centering(const Drawable &target = *Drawable::prime);
150 virtual QuickGabor& draw(Drawable &target = *Drawable::prime);
151 virtual QuickGabor& draw(int x, int y, Drawable &target = *Drawable::prime);