17#ifndef __filter_erode_h__
18#define __filter_erode_h__
26#include "filter/base.h"
52 template <
class HeaderType>
53 Erode (
const HeaderType& in) :
57 check_3D_nonunity (in);
61 template <
class HeaderType>
62 Erode (
const HeaderType& in,
const std::string&
message) :
66 check_3D_nonunity (in);
71 template <
class InputImageType,
class OutputImageType>
72 void operator() (InputImageType& input, OutputImageType& output)
76 std::shared_ptr <Image<bool> > out;
79 for (
unsigned int pass = 0; pass <
npass; pass++) {
81 for (
auto l =
Loop (*in) (*in, *out); l; ++l)
82 out->value() =
erode (*in);
93 void set_npass (
unsigned int npasses)
103 if (!in.value())
return false;
104 if ( (in.index(0) == 0) || (in.index(0) == in.
size(0)-1)
105 || (in.index(1) == 0) || (in.index(1) == in.
size(1)-1)
106 || (in.index(2) == 0) || (in.index(2) == in.
size(2)-1))
109 if (in.index(0) > 0) { in.index(0)--; val = in.value(); in.index(0)++;
if (!val)
return false; }
110 if (in.index(1) > 0) { in.index(1)--; val = in.value(); in.index(1)++;
if (!val)
return false; }
111 if (in.index(2) > 0) { in.index(2)--; val = in.value(); in.index(2)++;
if (!val)
return false; }
112 if (in.index(0) < in.
size(0)-1) { in.index(0)++; val = in.value(); in.index(0)--;
if (!val)
return false; }
113 if (in.index(1) < in.
size(1)-1) { in.index(1)++; val = in.value(); in.index(1)--;
if (!val)
return false; }
114 if (in.index(2) < in.
size(2)-1) { in.index(2)++; val = in.value(); in.index(2)--;
if (!val)
return false; }
static constexpr uint8_t Bit
bool erode(Image< bool > &in)
static Image scratch(const Header &template_header, const std::string &label="scratch image")
ssize_t size(size_t axis) const
implements a progress meter to provide feedback to the user
FORCE_INLINE LoopAlongAxes Loop()
void copy(InputImageType &&source, OutputImageType &&destination, size_t from_axis=0, size_t to_axis=std::numeric_limits< size_t >::max())