diff --git a/Base/include/Image.h b/Base/include/Image.h index ddd0428..1c70712 100644 --- a/Base/include/Image.h +++ b/Base/include/Image.h @@ -125,6 +125,8 @@ namespace FasTC { void ConvertFromBlockStreamOrder(); }; + extern void GenerateGaussianKernel(Image &out, uint32 size, float sigma); + } // namespace FasTC #endif // __TEXCOMP_IMAGE_H__ diff --git a/Base/src/Image.cpp b/Base/src/Image.cpp index 1e8561c..dcff088 100644 --- a/Base/src/Image.cpp +++ b/Base/src/Image.cpp @@ -350,4 +350,22 @@ template class Image; template class Image; template class Image; +void GenerateGaussianKernel(Image &out, uint32 size, float sigma) { + + assert(size % 2); + + out = Image(size, size); + if(size == 1) { + out(0, 0) = 1.0f; + return; + } + + int32 halfSz = static_cast(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