13 #ifndef IMAGE_CONVOLVE_HPP
14 #define IMAGE_CONVOLVE_HPP
27 :
image(L), yradius(yradius), xradius(xradius), mode(mode) { }
29 virtual double get(
int i,
int j,
int k)
const
38 for (
int y = -yradius; y <= yradius; y++)
39 for (
int x = -xradius; x <= xradius; x++)
40 if ((s = kernel(y, x)))
43 t += s *
L->
get(wrap(i + y, h, mode & 1),
44 wrap(j + x, w, mode & 2), k);
51 virtual double kernel(
int,
int)
const = 0;
71 int(ceil(sigma * 3)), mode, L), sigma(sigma) { }
73 virtual void tweak(
int a,
int v)
78 xradius = int(ceil(sigma * 3));
79 yradius = int(ceil(sigma * 3));
83 virtual double kernel(
int y,
int x)
const
85 return sigma ? exp(-0.5 * (x * x + y * y) / (sigma * sigma)) : 1.0;
88 virtual void doc(std::ostream& out)
const
90 out <<
"gaussian " << sigma <<
" " << mode;
109 :
convolve(int(ceil(sigma * 3)), 0, mode, L), sigma(sigma) { }
116 yradius = int(ceil(sigma * 3));
120 virtual double kernel(
int y,
int x)
const
122 return sigma ? exp(-0.5 * (y * y) / (sigma * sigma)) : 1.0;
125 virtual void doc(std::ostream& out)
const
127 out <<
"gaussianv " << sigma <<
" " << mode;
146 :
convolve(0, int(ceil(sigma * 3)), mode, L), sigma(sigma) { }
153 xradius = int(ceil(sigma * 3));
157 virtual double kernel(
int y,
int x)
const
159 return sigma ? exp(-0.5 * (x * x) / (sigma * sigma)) : 1.0;
162 virtual void doc(std::ostream& out)
const
164 out <<
"gaussianh " << sigma <<
" " << mode;
virtual double get(int i, int j, int k) const =0
Return the value of the sample at row i, column j, channel k.
image * L
Left child.
Definition: image.hpp:117
gaussianv(double sigma, int mode, image *L)
Convolve image L using a vertical 1D Gaussian kernel with standard deviation sigma. Mode gives the wrapping mode. The true radius of the kernel is 3 sigma, rounded up.
Definition: image_convolve.hpp:108
virtual void tweak(int a, int v)
Tweak image parameter a, changing the value by a factor of v.
Definition: image_convolve.hpp:111
Base class for all image sources, filters, and operators.
Definition: image.hpp:20
Gaussian convolution filter.
Definition: image_convolve.hpp:62
gaussian(double sigma, int mode, image *L)
Convolve image L using a Gaussian kernel with standard deviation sigma. Mode gives the wrapping mode...
Definition: image_convolve.hpp:69
virtual int get_height() const
Return the height of this image.
Definition: image.hpp:46
convolve(int yradius, int xradius, int mode, image *L)
Convolve image L using a kernel of the given yradius and xradius. The kernel is expected to be suppli...
Definition: image_convolve.hpp:26
Horizontal Gaussian convolution filter.
Definition: image_convolve.hpp:138
gaussianh(double sigma, int mode, image *L)
Convolve image L using a horizontal 1D Gaussian kernel with standard deviation sigma. Mode gives the wrapping mode. The true radius of the kernel is 3 sigma, rounded up.
Definition: image_convolve.hpp:145
virtual int get_width() const
Return the height of this image.
Definition: image.hpp:56
virtual void doc(std::ostream &out) const
Produce a string documenting the function of this object.
Definition: image_convolve.hpp:88
Vertical Gaussian convolution filter.
Definition: image_convolve.hpp:101
virtual void doc(std::ostream &out) const
Produce a string documenting the function of this object.
Definition: image_convolve.hpp:162
virtual void tweak(int a, int v)
Tweak image parameter a, changing the value by a factor of v.
Definition: image_convolve.hpp:73
Convolution filter.
Definition: image_convolve.hpp:20
virtual void tweak(int a, int v)
Tweak image parameter a, changing the value by a factor of v.
Definition: image_convolve.hpp:148
virtual void doc(std::ostream &out) const
Produce a string documenting the function of this object.
Definition: image_convolve.hpp:125