28 #include <Base/Common/BIASpragma.hh>
37 template <
class InputStorageType,
class OutputStorageType>
40 :
Convolution<InputStorageType, OutputStorageType>()
45 template <
class InputStorageType,
class OutputStorageType>
48 : _MeanSize(other._MeanSize)
52 template <
class InputStorageType,
class OutputStorageType>
59 template <
class InputStorageType,
class OutputStorageType>
63 BIASCDOUT(D_FILTERBASE_CALLSTACK,
"Mean::Filter\n");
71 res=FilterMean2x2(src, dst);
81 template <
class InputStorageType,
class OutputStorageType>
85 BIASERR(
"Unimplemented interface, calling generic Filter");
86 return Filter(src, dst);
89 template <
class InputStorageType,
class OutputStorageType>
93 BIASERR(
"Unimplemented interface, calling generic Filter");
94 return Filter(src, dst);
97 template <
class InputStorageType,
class OutputStorageType>
101 BIASCDOUT(D_FILTERBASE_CALLSTACK,
"Mean::FilterMean\n");
102 BIASERR(
"deprecated");
108 template <
class InputStorageType,
class OutputStorageType>
113 BIASCDOUT(D_FILTERBASE_CALLSTACK,
"Mean::FilterMean2x2Grey\n");
120 unsigned minx, miny, maxx, maxy;
129 register double sum, lsum;
130 register const InputStorageType *srcu, *srcl;
131 register OutputStorageType *pdst, *dstend, *dstlend;
132 register const int width=src.
GetWidth();
133 register const int step=width-(maxx-minx);
142 dstlend = pdst + width-step;
146 while (pdst < dstend){
147 lsum = (double)*srcu++ + (
double)*srcl++;
148 while (pdst < dstlend){
149 sum = (double)*srcu++ + (
double)*srcl++;
152 *pdst++ = (OutputStorageType)((sum + lsum)/ 2.0);
167 template <
class InputStorageType,
class OutputStorageType>
172 BIASCDOUT(D_FILTERBASE_CALLSTACK,
"Mean::FilterMean2x2\n");
180 res = FilterMean2x2Grey(src, dst);
192 template <
class InputStorageType,
class OutputStorageType>
194 const FM_FLOAT val = 1.0f/(FM_FLOAT)(_MeanSize);
196 for (
int i=0; i< _MeanSize; i++){
201 int thebits = _fm.ComputeIntPrecisionBits(
sizeof(InputStorageType)*8,
202 sizeof(CONV_INT)*8-1);
203 _fm.CreateIntFilter(thebits,thebits,thebits);
206 template <
class InputStorageType,
class OutputStorageType>
210 border_x = border_y = _MeanSize/2;
218 #define FILTER_INSTANTIATION_CLASS Mean
219 #include "Filterinst.hh"
void Release()
reimplemented from ImageBase
virtual int Filter(const Image< InputStorageType > &src, Image< OutputStorageType > &dst)
averages over a region with constant weights
generic convolution class.
int SetCorners(unsigned UpperLeftX, unsigned UpperLeftY, unsigned LowerRightX, unsigned LowerRightY)
Sets a rectangular region of interest.
void GetCorners(unsigned &UpperLeftX, unsigned &UpperLeftY, unsigned &LowerRightX, unsigned &LowerRightY) const
Return the region of interest, by saving the coordinates within the variables defined by the paramete...
bool IsEmpty() const
check if ImageData_ points to allocated image buffer or not
virtual void GetBordersValid_(int &border_x, int &border_y) const
virtual int Filter(const Image< InputStorageType > &src, Image< OutputStorageType > &dst)
decides on the image types which FilterFunction should be called
unsigned int GetWidth() const
virtual int FilterInt(const Image< InputStorageType > &src, Image< OutputStorageType > &dst)
only calls filter, for consistency of params
virtual int FilterFloat(const Image< InputStorageType > &src, Image< OutputStorageType > &dst)
only calls filter, for consistency of params
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
void _SetKernel()
sets the vector members of Convolution
int FilterMean2x2Grey(const Image< InputStorageType > &src, Image< OutputStorageType > &dst)
dst must be initialized: dst width = src width - 1, dst height = src height - 1 Does support ROI...
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 FilterMean(const Image< InputStorageType > &src, Image< OutputStorageType > &dst)
deprecated
enum EColorModel GetColorModel() const
int FilterMean2x2(const Image< InputStorageType > &src, Image< OutputStorageType > &dst)
dst width = src width - 1, dst height = src height - 1