32 template <
class InputStorageType,
class OutputStorageType>
42 #ifdef BIAS_BOUNDS_CHECK
44 BIASERR(
"Erosion<StorageType>::Dilate() only implemented for grey images");
46 BIASERR(
"Erosion<StorageType>::Dilate() wrong images sizes");
47 if (KernelSize % 2 != 1)
48 BIASERR(
"Erosion<StorageType>::Dilate() odd KernelSize required");
53 register int HalfKernelSize = (KernelSize - 1) / 2;
58 for (
register int y = HalfKernelSize;
59 y < (Height - HalfKernelSize); y++) {
60 for (
register int x = HalfKernelSize;
61 x < (Width - HalfKernelSize); x++) {
62 DestArray[y][x] = OutputStorageType(SourceArray[y][x]);
63 for (
register int ky = -HalfKernelSize; ky <= HalfKernelSize; ky++)
64 for (
register int kx = -HalfKernelSize; kx <= HalfKernelSize; kx++)
65 if ( (DestArray[y][x]==0) || (SourceArray[y+ky][x+kx]==0) )
71 this->FillBorderConst(Destination, (
unsigned short int)HalfKernelSize,
72 (
unsigned short int)HalfKernelSize, (OutputStorageType)0);
78 template <
class InputStorageType,
class OutputStorageType>
83 #ifdef BIAS_BOUNDS_CHECK
85 BIASERR(
"Erosion<StorageType>::Erode3Fast() only implemented for grey images");
89 BIASERR(
"Erosion<StorageType>::Erode3Fast(): src has less than 25 pixel");
93 BIASERR(
"Erosion<StorageType>::Erode3Fast(): src has less than 5 cols or rows");
97 BIASERR(
"Erosion<StorageType>::Erode3Fast(): src and dest have different sizes");
107 register const InputStorageType *p2=p1+1, *p3 = p2+1;
109 register const InputStorageType *p5 = p4+1, *p6=p5+1;
111 register const InputStorageType *p8 = p7+1, *p9=p8+1;
120 *d = OutputStorageType(*p5);
121 p2++; p4++; p5++; p6++; p8++; d++;
134 *d = OutputStorageType(*p5);
135 p1++; p2++; p3++; p4++; p5++; p6++; p7++; p8++; p9++; d++;
140 register OutputStorageType *o1, *o9, *o2, *olast;
155 o1+=offset; o2+=offset;
160 template <
class InputStorageType,
class OutputStorageType>
165 BIASERR(
"Erosion only for 1 channel images");
168 if (_FilterBorderHandling==TBH_valid) {
169 if (kernelSize_==3) {
172 Erode3Fast(src,dst,
false);
175 Erode(src,dst,kernelSize_);
178 }
else if (_FilterBorderHandling==TBH_same) {
181 src.
GetHeight()+ int(kernelSize_/2)*2,1);
188 Erode(tmp,dst,kernelSize_);
194 BIASERR(
"borderhandling not implemnted/");
200 template <
class InputStorageType,
class OutputStorageType>
204 BIASERR(
"no parameter support");
214 #define FILTER_INSTANTIATION_CLASS Erosion
215 #include "Filterinst.hh"
void Release()
reimplemented from ImageBase
virtual int Filter(const Image< InputStorageType > &src, Image< OutputStorageType > &dst)
Does the erosion.
int Cut2ROI()
reduces image to current ROI, !!! image size changes !!!
int SetCorners(unsigned UpperLeftX, unsigned UpperLeftY, unsigned LowerRightX, unsigned LowerRightY)
Sets a rectangular region of interest.
bool IsEmpty() const
check if ImageData_ points to allocated image buffer or not
void SetColorModel(EColorModel Model)
unsigned int GetWidth() const
ROI * GetROI()
Returns a pointer to the roi object.
unsigned int GetChannelCount() const
returns the number of Color channels, e.g.
unsigned int GetHeight() const
int Erode3Fast(const Image< InputStorageType > &src, Image< OutputStorageType > &dest, bool Neighbor4=false)
Very fast erode with 3x3 mask, all values, which are not not zero, are treated as foreground...
void FillImageWithConstValue(StorageType Value)
fill grey images
bool SamePixelAndChannelCount(const ImageBase &Image) const
checks if data area has same "size" as Image of other type
void Init(unsigned int Width, unsigned int Height, unsigned int channels=1, enum EStorageType storageType=ST_unsignedchar, const bool interleaved=true)
calls Init from ImageBase storageType is ignored, just dummy argument
const StorageType * GetImageData() const
overloaded GetImageData() from ImageBase
int Paste2ROI(const ImageBase &Image)
paste Image to current ROI
virtual void GetBordersValid_(int &border_x, int &border_y) const
unsigned long int GetPixelCount() const
returns number of pixels in image
int Erode(const Image< InputStorageType > &Source, Image< OutputStorageType > &Destination, int KernelSize=3)
erode with square kernel filled with 255
const StorageType ** GetImageDataArray() const
overloaded GetImageDataArray() from ImageBase