iRoCS Toolbox  1.1.0
DistanceTransform.hh
Go to the documentation of this file.
1 /**************************************************************************
2  *
3  * Euclidean Distance Transform
4  *
5  * This file provides a class to store microscopic datasets with
6  * element size and a transformation to apply. It provides a function
7  * valueAt() to first apply the transformation and then access
8  * the transformed position using the specified ArrayInterpolator.
9  *
10  * This file belongs to the iRoCS Toolbox.
11  *
12  * Copyright (C) 2008-2018 Thorsten Falk
13  *
14  * This program is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation; either version 3 of the License, or
17  * (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with this program; if not, write to the Free Software Foundation,
26  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
27  *
28  **************************************************************************/
29 
30 /*======================================================================*/
36 /*======================================================================*/
37 
38 #ifndef ATBDISTANCETRANSFORM_HH
39 #define ATBDISTANCETRANSFORM_HH
40 
41 #ifdef HAVE_CONFIG_H
42 #include <config.hh>
43 #endif
44 
46 
47 #include "Array.hh"
48 
49 namespace atb {
50 
51 /*======================================================================*/
63 /*======================================================================*/
65  {
66 
67 /*======================================================================*/
73 /*======================================================================*/
74  enum Mode {
79 
80 /*======================================================================*/
84 /*======================================================================*/
85  static double BG_VALUE;
86 
87 /*======================================================================*/
94 /*======================================================================*/
95  EuclideanDistanceTransformBase(int capacity);
96 
97 /*======================================================================*/
101 /*======================================================================*/
103 
104 /*======================================================================*/
116 /*======================================================================*/
117  void run(int n);
118 
119 /*======================================================================*/
126 /*======================================================================*/
127  std::vector<double> f;
128 
129 /*======================================================================*/
133 /*======================================================================*/
134  std::vector<double> d;
135 
136 /*======================================================================*/
140 /*======================================================================*/
141  std::vector<double> _z;
142 
143 /*======================================================================*/
148 /*======================================================================*/
149  std::vector<double> _v;
150 
151  };
152 
153 /*======================================================================*/
159 /*======================================================================*/
160  template<typename DataT, int Dim>
162  {
163 
164  public:
165 
166 /*======================================================================*/
180 /*======================================================================*/
181  static void getDistanceInPixels(
182  Array<double,Dim> &distances,
183  Array<DataT,Dim> const &data,
186  DataT fg = traits<DataT>::one, iRoCS::ProgressReporter *pr = NULL);
187 
188 /*======================================================================*/
202 /*======================================================================*/
203  static void getNearestPixels(
204  Array<blitz::TinyVector<BlitzIndexT,Dim>,Dim> &nearestPixels,
205  Array<DataT,Dim> const &data,
208  DataT fg = traits<DataT>::one, iRoCS::ProgressReporter *pr = NULL);
209 
210 /*======================================================================*/
225 /*======================================================================*/
226  static void getDistanceInPixels(
227  blitz::Array<double,Dim> &distances,
228  blitz::Array<DataT,Dim> const &data,
229  blitz::TinyVector<double,Dim> const &,
232  DataT fg = traits<DataT>::one, iRoCS::ProgressReporter *pr = NULL);
233 
234 /*======================================================================*/
249 /*======================================================================*/
250  static void getNearestPixels(
251  blitz::Array<blitz::TinyVector<BlitzIndexT,Dim>,Dim> &nearestPixels,
252  blitz::Array<DataT,Dim> const &data,
253  blitz::TinyVector<double,Dim> const &,
256  DataT fg = traits<DataT>::one, iRoCS::ProgressReporter *pr = NULL);
257 
258  };
259 
260 }
261 
262 #include "DistanceTransform.icc"
263 
264 #endif
Array class derived from blitz++ Arrays for handling microscopic datasets with associated element siz...
Compute distance to nearest background pixel.
Mode
DistanceTransform.hh "libArrayToolbox/DistanceTransform.hh".
The Array class is an extension to the blitz++ Array class providing additional parameters element si...
Definition: Array.hh:85
static double BG_VALUE
Assign background pixels this value and foreground pixels value 0.
std::vector< double > _z
The intervals of parabola contributing to the lower distance envelope.
std::vector< double > f
The input to process the distance transform for.
The traits class provides means to query specific information about different data types...
Definition: TypeTraits.hh:73
The DistanceTransform class computes the exact euclidean distance transform of binary images...
std::vector< double > _v
The angular points of parabola contributing to the lower distance envelope.
Compute distance to nearest foreground pixel.
void run(int n)
Apply the line transform to data stored in f.
EuclideanDistanceTransformBase(int capacity)
Create a new EuclideanDistanceTransformBase object with given maximum line length.
std::vector< double > d
The squared eucliden distances of f.
Exact 1-D euclidean distance transform using lower parabola embedding [1].