1 #include "DistTransform.hh"
4 #include "Base/Image/ImageConvert.hh"
13 template <
class InputStorageType,
class OutputStorageType>
16 :
FilterNToN<InputStorageType, OutputStorageType>()
21 template <
class InputStorageType,
class OutputStorageType>
24 :
FilterNToN<InputStorageType, OutputStorageType>(other),
25 zeroLevel_(other.zeroLevel_)
29 template <
class InputStorageType,
class OutputStorageType>
36 OutputStorageType maxVal=
41 for (
int i = 0; i < pixels; i++)
42 if (data[i]==zeroLevel_) data[i] = 0;
43 else data[i] = maxVal;
47 template <
class InputStorageType,
class OutputStorageType>
51 #define mymin(a,b) ((a<=b)?a:b)
52 #define minDEF(s0,s1,s2,s3,s4) mymin(s0, mymin(s1, mymin(s2, mymin(s3, s4))))
60 for (
int k = 1; k <= rows-1; k++)
61 for (
int j = 1; j <= cols-1-1; j++)
62 data[k][j]= minDEF(data[k][j],
63 OutputStorageType(data[k][j-1]+3),
64 OutputStorageType(data[k-1][j]+3),
65 OutputStorageType(data[k-1][j-1]+4),
66 OutputStorageType(data[k-1][j+1]+4) );
69 for (
int k = rows-1-1; k >= 0; k--)
70 for (
int j = cols-1-1; j >= 1; j--)
73 OutputStorageType(data[k][j+1]+3),
74 OutputStorageType(data[k+1][j]+3),
75 OutputStorageType(data[k+1][j+1]+4),
76 OutputStorageType(data[k+1][j-1]+4) );
80 template <
class InputStorageType,
class OutputStorageType>
87 BIASERR(
"OutputType unsigned char is invalid for distance images, "
88 "use unsigned short or float!");
93 InitDistanceImage_(dist_img);
94 MakeDistanceImage_(dist_img);
98 template <
class InputStorageType,
class OutputStorageType>
102 BIASERR(
"FilterInt makes no sense here, using general Filter interface.");
103 return Filter(src, dst);
106 template <
class InputStorageType,
class OutputStorageType>
110 BIASERR(
"FilterFloat makes no sense here, using general Filter interface.");
111 return Filter(src, dst);
114 template <
class InputStorageType,
class OutputStorageType>
118 BIASERR(
"Unfinished code");
126 #define FILTER_INSTANTIATION_CLASS DistTransform
127 #include "Filterinst.hh"
unsigned int GetWidth() const
static int ConvertST(const BIAS::ImageBase &source, BIAS::ImageBase &dest, ImageBase::EStorageType targetST)
Function to convert the storage type of images e.g.
base class for simple n->n filter implementations
unsigned int GetHeight() const
const StorageType * GetImageData() const
overloaded GetImageData() from ImageBase
enum EStorageType GetStorageType() const
(8bit) unsigned char image storage type
unsigned long int GetPixelCount() const
returns number of pixels in image
const StorageType ** GetImageDataArray() const
overloaded GetImageDataArray() from ImageBase