This commit is contained in:
toni
2018-01-17 10:26:16 +01:00
67 changed files with 16100 additions and 2117 deletions

View File

@@ -3,6 +3,7 @@
#include <cmath>
#include <vector>
#include "Image2D.h"
#include "BoxSizes.h"
template <class T>
@@ -28,7 +29,7 @@ struct BoxGaus
{
BoxSizes<T> bsX(sigmaX, nFilt);
BoxSizes<T> bsY(sigmaY, nFilt);
std::vector<T> buffer(input.size());
std::vector<T> buffer(input.size());
assertMsg((2 * bsX.wl + 1 < w) && (2 * bsX.wl + 1 < h), "Box-Filter size in X direction is too big");
assertMsg((2 * bsX.wu + 1 < w) && (2 * bsX.wu + 1 < h), "Box-Filter size in X direction is too big");
@@ -89,7 +90,7 @@ private:
for (size_t j = 0; j <= r; j++)
{
val += src[ri] - fv;
dst[j + i*w] = val * iarr;
dst[i + j*w] = val * iarr;
ri += w;
ti += w;
@@ -99,7 +100,7 @@ private:
for (size_t j = r + 1; j < h - r; j++)
{
val += src[ri] - src[li];
dst[j + i*w] = val * iarr;
dst[i + j*w] = val * iarr;
li += w;
ri += w;
@@ -110,12 +111,14 @@ private:
for (size_t j = h - r; j < h; j++)
{
val += lv - src[li];
dst[j + i*w] = val * iarr;
dst[i + j*w] = val * iarr;
li += w;
ti += w;
}
}
int test = 0;
}
};

View File

@@ -174,7 +174,6 @@ struct Image2D : public ImageView2D<TValue>
assertMsg(data.size() == width*height, "Sizes must be the same");
this->values = values_vec.data();
}
std::vector<TValue>& data() { return values_vec; }
const std::vector<TValue>& data() const { return values_vec; }

View File

@@ -2,6 +2,9 @@
#include <chrono>
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
template <typename F>
static void benchmark(std::string name, size_t count, F&& lambda)
@@ -102,4 +105,4 @@ public:
lapTime = clock::now();
}
};
};

View File

@@ -26,8 +26,13 @@ namespace Distribution {
Normal(const T mu, const T sigma) :
mu(mu), sigma(sigma), _a(1.0 / (sigma * std::sqrt(2.0 * M_PI))), gen(RANDOM_SEED), dist(mu,sigma) {
#warning "analyze issue when coping an existing distribution and using draw() afterwards. this seems to yield issues"
}
/** do not allow copy. this will not work as expected for std::normal_distribution when using draw() ?! */
//Normal(const Normal& o) = delete;
/** get probability for the given value */
T getProbability(const T val) const {
const T b = -0.5 * ((val-mu)/sigma) * ((val-mu)/sigma);

63
math/speed.h Normal file
View File

@@ -0,0 +1,63 @@
#ifndef SPEED_H
#define SPEED_H
#include <cmath>
class Speed {
public:
#define PI_FLOAT 3.14159265f
#define PIBY2_FLOAT 1.5707963f
static inline float atan2(float y, float x) {
//http://pubs.opengroup.org/onlinepubs/009695399/functions/atan2.html
//Volkan SALMA
const float ONEQTR_PI = M_PI / 4.0;
const float THRQTR_PI = 3.0 * M_PI / 4.0;
float r, angle;
float abs_y = fabs(y) + 1e-10f; // kludge to prevent 0/0 condition
if ( x < 0.0f ) {
r = (x + abs_y) / (abs_y - x);
angle = THRQTR_PI;
} else {
r = (x - abs_y) / (x + abs_y);
angle = ONEQTR_PI;
}
angle += (0.1963f * r * r - 0.9817f) * r;
if ( y < 0.0f )
return( -angle ); // negate if in quad III or IV
else
return( angle );
}
// // https://gist.github.com/volkansalma/2972237
// static inline float atan2(const float y, const float x) {
// if ( x == 0.0f ) {
// if ( y > 0.0f ) return PIBY2_FLOAT;
// if ( y == 0.0f ) return 0.0f;
// return -PIBY2_FLOAT;
// }
// float atan;
// float z = y/x;
// if ( fabs( z ) < 1.0f ) {
// atan = z/(1.0f + 0.28f*z*z);
// if ( x < 0.0f ) {
// if ( y < 0.0f ) return atan - PI_FLOAT;
// return atan + PI_FLOAT;
// }
// } else {
// atan = PIBY2_FLOAT - z/(z*z + 0.28f);
// if ( y < 0.0f ) return atan - PI_FLOAT;
// }
// return atan;
// }
};
#endif // SPEED_H