Add Gaussian kernel generating function.

This commit is contained in:
Pavel Krajcevski 2013-10-10 20:06:12 -04:00
parent 654ee23446
commit bf5429cd0c
2 changed files with 20 additions and 0 deletions

View file

@ -125,6 +125,8 @@ namespace FasTC {
void ConvertFromBlockStreamOrder(); void ConvertFromBlockStreamOrder();
}; };
extern void GenerateGaussianKernel(Image<IPixel> &out, uint32 size, float sigma);
} // namespace FasTC } // namespace FasTC
#endif // __TEXCOMP_IMAGE_H__ #endif // __TEXCOMP_IMAGE_H__

View file

@ -350,4 +350,22 @@ template class Image<Pixel>;
template class Image<IPixel>; template class Image<IPixel>;
template class Image<Color>; template class Image<Color>;
void GenerateGaussianKernel(Image<IPixel> &out, uint32 size, float sigma) {
assert(size % 2);
out = Image<IPixel>(size, size);
if(size == 1) {
out(0, 0) = 1.0f;
return;
}
int32 halfSz = static_cast<int32>(size) / 2;
for(int32 j = -halfSz; j < halfSz; j++) {
for(int32 i = -halfSz; i < halfSz; i++) {
out(i, j) = exp(- (j*j + i*i) / (2*sigma*sigma));
}
}
}
} // namespace FasTC } // namespace FasTC