25 #include "TukeyWindow.hh"
28 template <
class InputStorageType,
class OutputStorageType>
30 :
FilterNToN<InputStorageType,OutputStorageType>()
36 template <
class InputStorageType,
class OutputStorageType>
39 :
FilterNToN<InputStorageType,OutputStorageType>()
45 template <
class InputStorageType,
class OutputStorageType>
48 :
FilterNToN<InputStorageType, OutputStorageType>(other)
50 ratio_ = other.ratio_;
53 template <
class InputStorageType,
class OutputStorageType>
58 template <
class InputStorageType,
class OutputStorageType>
61 return FilterFloat(src, dst);
64 template <
class InputStorageType,
class OutputStorageType>
67 return FilterFloat(src, dst);
70 template <
class InputStorageType,
class OutputStorageType>
75 BIASWARN(
"implicit type conversion");
84 dst.
Init(w+2*zeropad_,h+2*zeropad_,ch);
86 dst.
ReInit(w+2*zeropad_,h+2*zeropad_,ch);
93 BIASERR(
"Not implemented!");
96 float per = ratio_ / 2.0f;
97 unsigned int wtl = (
unsigned int)floor(per*(w-1));
98 unsigned int wth = w-wtl-1;
99 unsigned int htl = (
unsigned int)floor(per*(h-1));
100 unsigned int hth = h-htl-1;
105 for (
unsigned int y=0;y<h;y++) {
106 for (
unsigned int x=0;x<w;x++) {
107 for (
unsigned int c=0;c<ch;c++) {
108 OutputStorageType curval = (OutputStorageType) idaIn[y][x*ch+c];
111 float idx = float(x)/float(wtl);
112 curval = curval * (OutputStorageType)((1+cos((1.0f - idx) * M_PI)) / 2.0f);
115 float idx = float(x-wth)/float(w-wth-1);
116 curval = curval * (OutputStorageType)((1+cos(idx * M_PI)) / 2.0f);
119 float idx = float(y)/float(htl);
120 curval = curval * (OutputStorageType)((1+cos((1.0f - idx) * M_PI)) / 2.0f);
123 float idx = float(y-hth)/float(h-hth-1);
124 curval = curval * (OutputStorageType)((1+cos(idx * M_PI)) / 2.0f);
126 idaOut[y+zeropad_][(x+zeropad_)*ch+c] = curval;
136 #define FILTER_INSTANTIATION_CLASS TukeyWindow
137 #include "Filterinst.hh"
Multiplies an image with a full image size tukey window.
virtual int Filter(const Image< InputStorageType > &src, Image< OutputStorageType > &dst)
virtual function for interface definition
bool IsEmpty() const
check if ImageData_ points to allocated image buffer or not
virtual int FilterFloat(const Image< InputStorageType > &src, Image< OutputStorageType > &dst)
unsigned int GetWidth() const
void ReInit(const unsigned int &width, const unsigned int &height, const unsigned int nChannels=1, const enum EStorageType storageType=ST_unsignedchar, const bool interleaved=true, const EColorModel colormodel=CM_Grey)
(Re-)Initialize Image data if required.
unsigned int GetChannelCount() const
returns the number of Color channels, e.g.
base class for simple n->n filter implementations
unsigned int GetHeight() const
void FillImageWithConstValue(StorageType Value)
fill grey images
virtual int FilterInt(const Image< InputStorageType > &src, Image< OutputStorageType > &dst)
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
enum EStorageType GetStorageType() const
TukeyWindow()
Default Constructor, ratio 0.5, zeropad 0.
const StorageType ** GetImageDataArray() const
overloaded GetImageDataArray() from ImageBase