mirror of
https://github.com/yuzu-emu/FasTC
synced 2024-11-23 15:34:05 +00:00
Add Gaussian kernel generating function.
This commit is contained in:
parent
654ee23446
commit
bf5429cd0c
2 changed files with 20 additions and 0 deletions
|
@ -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__
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue