aimstil  5.0.5
chamferDistance.h
Go to the documentation of this file.
1 #ifndef TIL_CHAMFERDISTANCE_H
2 #define TIL_CHAMFERDISTANCE_H
3 
4 #include <vector>
5 
6 #include "til/til_common.h"
7 
9 
10 namespace til
11 {
12 
13  template < typename TImage >
15  (
16  TImage &im,
17  const std::vector<typename TImage::value_type> &mask,
18  typename TImage::value_type foreground,
19  typename TImage::value_type background
20  )
21  {
22  typedef typename TImage::value_type value_type;
28  const value_type k_doNotProcess = std::numeric_limits<value_type>::is_signed ? -1 : std::numeric_limits<value_type>::max();
29  const value_type k_infinity = std::numeric_limits<value_type>::is_signed ? std::numeric_limits<value_type>::max() : std::numeric_limits<value_type>::max()-1;
30 
31  // Initialize the image by putting initial distances
32  {
33  typename Iterator<TImage>::Linear iIm(im);
34  for (; !iIm.isAtEnd(); ++iIm)
35  {
36  if (*iIm == foreground)
37  {
38  // Distance to object within object is zero
39  *iIm = 0;
40  }
41  else if (*iIm == background)
42  {
43  // Distance to object is infinity
44  *iIm = k_infinity;
45  }
46  else
47  {
48  // Special label for other objects present in the image
49  *iIm = k_doNotProcess;
50  }
51  }
52  }
53 
54  //
55  {
56  typename Iterator<TImage>::Volumetric iIm(im);
57 
58  value_type x = mask[0];
59  value_type y = mask[1];
60  value_type z = mask[2];
61 
62  //ConstantExtrapolator
63 
64  for (; !iIm.isAtEnd(); ++iIm)
65  {
66  //*iIm = MIN(*iIm, iIm.getValue(-1,0,0) * x);
67  }
68  }
69  }
70 
71 
72 } // namespace
73 
74 
75 #endif
76 
A trait class to assign iterators to image types.
Belongs to package Box Do not include directly, include til/Box.h instead.
Definition: Accumulator.h:10
General macros, definitions and functions.
TImage::value_type max(const TImage &im)
Returns the maximum intensity of the input image.
void chamferDistance_3(TImage &im, const std::vector< typename TImage::value_type > &mask, typename TImage::value_type foreground, typename TImage::value_type background)