13 #ifndef IMAGE_MORPHOLOGY_HPP
14 #define IMAGE_MORPHOLOGY_HPP
29 :
image(L), radius(radius), mode(mode) { }
31 virtual double get(
int i,
int j,
int k)
const
36 double v = std::numeric_limits<double>::min();
38 for (
int y = -radius; y <= +radius; y++)
39 for (
int x = -radius; x <= +radius; x++)
41 if (x * x + y * y <= radius * radius)
42 v = std::max(v,
L->
get(wrap(i + y, h, mode & 1),
43 wrap(j + x, w, mode & 2), k));
47 virtual void doc(std::ostream& out)
const
49 out <<
"dilate " << radius <<
" " << mode;
70 :
image(L), radius(radius), mode(mode) { }
72 virtual double get(
int i,
int j,
int k)
const
77 double v = std::numeric_limits<double>::max();
79 for (
int y = -radius; y <= +radius; y++)
80 for (
int x = -radius; x <= +radius; x++)
82 if (x * x + y * y <= radius * radius)
83 v = std::min(v,
L->
get(wrap(i + y, h, mode & 1),
84 wrap(j + x, w, mode & 2), k));
88 virtual void doc(std::ostream& out)
const
90 out <<
"erode " << radius <<
" " << 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.
Dilation filter.
Definition: image_morphology.hpp:20
image * L
Left child.
Definition: image.hpp:117
dilate(int radius, int mode, image *L)
Apply a morphological dilate with a circular kernel of the given radius to image L, wrapped by the given mode. The dilate filter gives the maximum value found among all pixels within the kernel footprint.
Definition: image_morphology.hpp:28
Base class for all image sources, filters, and operators.
Definition: image.hpp:20
virtual int get_height() const
Return the height of this image.
Definition: image.hpp:46
virtual void doc(std::ostream &out) const
Produce a string documenting the function of this object.
Definition: image_morphology.hpp:47
virtual int get_width() const
Return the height of this image.
Definition: image.hpp:56
erode(int radius, int mode, image *L)
Apply a morphological erode with a circular kernel of the given radius to image L, wrapped by the given mode. The erode filter gives the minimum value found among all pixels within the kernel footprint.
Definition: image_morphology.hpp:69
virtual void doc(std::ostream &out) const
Produce a string documenting the function of this object.
Definition: image_morphology.hpp:88
Erosion filter.
Definition: image_morphology.hpp:61