12 # include <vcl_msvc_warnings.h> 19 template <
class T,
class Iter>
21 unsigned n,
unsigned r)
24 for (
unsigned i=0;i<n;++i,++
v) *
v=im[offset[i]];
25 std::nth_element(values, values+r, values+n);
38 std::vector<T>& values,
double r)
41 std::size_t n = element.
p_i().size();
42 for (std::size_t k=0;k<n;++k)
44 unsigned int i = i0+element.
p_i()[k];
45 unsigned int j = j0+element.
p_j()[k];
46 if (i<image.
ni() && j<image.
nj())
47 values.push_back(image(i,j,plane));
49 std::nth_element(values.begin(),values.begin()+std::size_t(r*(values.size()-1)),
51 return values[std::size_t(r*(values.size()-1))];
64 #endif // vil_median_h_ Structuring element for morphology represented as a list of non-zero pixels.
const std::vector< int > & p_j() const
j position of elements (i,j).
Structuring element for morphology represented as a list of non-zero pixels.
Concrete view of image data of type T held in memory.
void vil_median(const vil_image_view< T > &src_image, vil_image_view< T > &dest_image, const vil_structuring_element &element)
Computes median value of pixels under structuring element.
unsigned ni() const
Width.
unsigned nj() const
Height.
T vil_sorted_value(const vil_image_view< T > &image, unsigned plane, const vil_structuring_element &element, int i0, int j0, std::vector< T > &values, double r)
Return (n*r)-th sorted value of pixels under element centred at (i0,j0).
A base class reference-counting view of some image data.
const std::vector< int > & p_i() const
i position of elements (i,j).