mirror of
https://github.com/yuzu-emu/FasTC.git
synced 2024-11-28 01:14:24 +01:00
Add Gaussian kernel generating function.
This commit is contained in:
parent
654ee23446
commit
bf5429cd0c
@ -125,6 +125,8 @@ namespace FasTC {
|
||||
void ConvertFromBlockStreamOrder();
|
||||
};
|
||||
|
||||
extern void GenerateGaussianKernel(Image<IPixel> &out, uint32 size, float sigma);
|
||||
|
||||
} // namespace FasTC
|
||||
|
||||
#endif // __TEXCOMP_IMAGE_H__
|
||||
|
@ -350,4 +350,22 @@ template class Image<Pixel>;
|
||||
template class Image<IPixel>;
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user