9 #ifndef DOXYGEN_SHOULD_SKIP_THIS 13 template <
typename T,
int dim>
class Image;
14 template <
typename T>
class PixelTraits;
17 template <
typename T,
int dim>
class NeumannBorder {
19 T operator() (
const Image<T,dim> &I,
const Coords<dim> &p)
const {
21 for (
int i=0;i<dim;i++) {
22 if (p[i]>=I.size(i)) q[i] = I.size(i)-1;
23 else if (p[i]<0) q[i] = 0;
31 template <
typename T,
int dim>
class DirichletBorder {
33 DirichletBorder(T out = T(0)) : _out(out) {}
35 T operator() (
const Image<T,dim> &I,
const Coords<dim> &p)
const {
36 for (
int i=0;i<dim;i++) {
37 if (p[i]>=I.size(i))
return _out;
38 if (p[i]<0)
return _out;
47 template <
typename T,
int dim>
class MirrorBorder {
49 T operator() (
const Image<T,dim> &I,
const Coords<dim> &p)
const {
51 for (
int i=0;i<dim;++i) {
52 if (q[i]<0) q[i] = -q[i];
53 if (q[i]>=I.size(i)) {
54 q[i] = q[i]%(2*I.size(i)-2);
55 if (q[i]>=I.size(i)) q[i] = 2*I.size(i)-2-q[i];
64 template <
typename T,
int dim>
class InvMirrorBorder {
66 T operator() (
const Image<T,dim> &I,
const Coords<dim> &p)
const {
68 for (
int i=0;i<dim;++i) {
69 if (p[i]>=I.size(i)) m[i] = I.size(i)-1;
70 else if (p[i]<0) m[i] = 0;
72 if (q[i]<0) q[i] = -q[i];
73 if (q[i]>=I.size(i)) {
74 q[i] = q[i]%(2*I.size(i)-2);
75 if (q[i]>=I.size(i)) q[i] = 2*I.size(i)-2-q[i];
79 return I(m)*
typename PixelTraits<T>::scalar_type(2)-I(q);
86 template <
typename T,
int dim,
class BorderCondition>
inline T border(
const Image<T,dim> &I,
const Coords<dim> &x,
const BorderCondition &bc) {
90 template <
typename T,
class BorderCondition>
inline T border(
const Image<T,1> &I,
int x,
const BorderCondition &bc) {
91 return border(I, Coords<1>(x), bc);
94 template <
typename T,
class BorderCondition>
inline T border(
const Image<T,2> &I,
int x,
int y,
const BorderCondition &bc) {
95 return border(I, Coords<2>(x,y), bc);
98 template <
typename T,
class BorderCondition>
inline T border(
const Image<T,3> &I,
int x,
int y,
int z,
const BorderCondition &bc) {
99 return border(I, Coords<3>(x,y,z), bc);
Imagine++ namespace.
Definition: Array.h:7