X-Git-Url: http://git.euphorik.ch/index.cgi?a=blobdiff_plain;f=WCudaMSE%2FTuto_Image_Cuda%2Fsrc%2Fcpp%2Fcore%2F01_Vague_smart%2Fmoo%2Fdevice%2Fmath%2FVagueMath.h;fp=WCudaMSE%2FTuto_Image_Cuda%2Fsrc%2Fcpp%2Fcore%2F01_Vague_smart%2Fmoo%2Fdevice%2Fmath%2FVagueMath.h;h=d4bc3357c41d3860b0cdbd98a99c3d0279fcb4a9;hb=8d08c12b29c2a14684f35c023ee39e694bb80d25;hp=0000000000000000000000000000000000000000;hpb=226de81f7e1f1fbf4ac79d0d089e8a05ec7159a0;p=GPU.git diff --git a/WCudaMSE/Tuto_Image_Cuda/src/cpp/core/01_Vague_smart/moo/device/math/VagueMath.h b/WCudaMSE/Tuto_Image_Cuda/src/cpp/core/01_Vague_smart/moo/device/math/VagueMath.h new file mode 100755 index 0000000..d4bc335 --- /dev/null +++ b/WCudaMSE/Tuto_Image_Cuda/src/cpp/core/01_Vague_smart/moo/device/math/VagueMath.h @@ -0,0 +1,83 @@ +#ifndef VAGUE_MATH_H_ +#define VAGUE_MATH_H_ + +#include "MathTools.h" + +/*----------------------------------------------------------------------*\ + |* Declaration *| + \*---------------------------------------------------------------------*/ + +/*--------------------------------------*\ + |* Public *| + \*-------------------------------------*/ + +class VagueMath + { + + /*--------------------------------------*\ + |* Constructor *| + \*-------------------------------------*/ + + public: + + __device__ VagueMath(int w, int h) + { + this->factor = 4 * PI / (float) w; + } + + __device__ VagueMath(const VagueMath& source) + { + // rien + } + + /*--------------------------------------*\ + |* Methodes *| + \*-------------------------------------*/ + + public: + + /** + * x=pixelI + * y=pixelJ + */ + __device__ + void colorIJ(uchar4* ptrColor, int i, int j, float t) + { + unsigned char levelGris; + + f(levelGris, i, j, t); // update levelGris + + ptrColor->x = levelGris; + ptrColor->y = levelGris; + ptrColor->z = levelGris; + + ptrColor->w = 255; // opaque + } + + private: + + __device__ + void f(unsigned char& levelGris, int i, int j, float t) + { + // Example1 + //unsigned char levelGris= 255 * abs(sin(t)); // same color for all the image (Hello image) + + // Example2 + levelGris = 255 * fabs(sin(i * factor + t)); + } + + /*--------------------------------------*\ + |* Attributs *| + \*-------------------------------------*/ + + private: + + double factor; + + }; + +#endif + +/*----------------------------------------------------------------------*\ + |* End *| + \*---------------------------------------------------------------------*/