|
@@ -46,7 +46,7 @@ static void normalize(std::vector<float> &mask) {
|
|
/* make filters */
|
|
/* make filters */
|
|
#define MAKE_FILTER(name, fun) \
|
|
#define MAKE_FILTER(name, fun) \
|
|
static std::vector<float> make_ ## name (float sigma) { \
|
|
static std::vector<float> make_ ## name (float sigma) { \
|
|
- sigma = std::max(sigma, 0.01F); \
|
|
|
|
|
|
+ sigma = std::max(sigma, 0.01F); \
|
|
int len = (int)ceil(sigma * WIDTH) + 1; \
|
|
int len = (int)ceil(sigma * WIDTH) + 1; \
|
|
std::vector<float> mask(len); \
|
|
std::vector<float> mask(len); \
|
|
for (int i = 0; i < len; i++) { \
|
|
for (int i = 0; i < len; i++) { \
|
|
@@ -58,7 +58,7 @@ static std::vector<float> make_ ## name (float sigma) { \
|
|
MAKE_FILTER(fgauss, exp(-0.5*square(i/sigma)));
|
|
MAKE_FILTER(fgauss, exp(-0.5*square(i/sigma)));
|
|
|
|
|
|
/* convolve image with gaussian filter */
|
|
/* convolve image with gaussian filter */
|
|
-static image<float> *smooth(image<float> *src, float sigma) {
|
|
|
|
|
|
+static image<float> *smooth2(image<float> *src, float sigma) {
|
|
std::vector<float> mask = make_fgauss(sigma);
|
|
std::vector<float> mask = make_fgauss(sigma);
|
|
normalize(mask);
|
|
normalize(mask);
|
|
|
|
|
|
@@ -72,9 +72,9 @@ static image<float> *smooth(image<float> *src, float sigma) {
|
|
}
|
|
}
|
|
|
|
|
|
/* convolve image with gaussian filter */
|
|
/* convolve image with gaussian filter */
|
|
-image<float> *smooth(image<uchar> *src, float sigma) {
|
|
|
|
|
|
+static image<float> *smooth(image<uchar> *src, float sigma) {
|
|
image<float> *tmp = imageUCHARtoFLOAT(src);
|
|
image<float> *tmp = imageUCHARtoFLOAT(src);
|
|
- image<float> *dst = smooth(tmp, sigma);
|
|
|
|
|
|
+ image<float> *dst = smooth2(tmp, sigma);
|
|
delete tmp;
|
|
delete tmp;
|
|
return dst;
|
|
return dst;
|
|
}
|
|
}
|