X-Git-Url: http://git.euphorik.ch/index.cgi?a=blobdiff_plain;f=WCudaMSE%2FTuto_Image_Cuda%2Fsrc%2Fcpp%2Fcore%2F00_Vague_warmup%2F03_math%2FVague0Math.h;fp=WCudaMSE%2FTuto_Image_Cuda%2Fsrc%2Fcpp%2Fcore%2F00_Vague_warmup%2F03_math%2FVague0Math.h;h=83eedf3cee743ae185e33f1a332fcdd4774d8a87;hb=8d08c12b29c2a14684f35c023ee39e694bb80d25;hp=0000000000000000000000000000000000000000;hpb=226de81f7e1f1fbf4ac79d0d089e8a05ec7159a0;p=GPU.git diff --git a/WCudaMSE/Tuto_Image_Cuda/src/cpp/core/00_Vague_warmup/03_math/Vague0Math.h b/WCudaMSE/Tuto_Image_Cuda/src/cpp/core/00_Vague_warmup/03_math/Vague0Math.h new file mode 100755 index 0000000..83eedf3 --- /dev/null +++ b/WCudaMSE/Tuto_Image_Cuda/src/cpp/core/00_Vague_warmup/03_math/Vague0Math.h @@ -0,0 +1,83 @@ +#ifndef VAGUE_0_MATH_ +#define VAGUE_0_MATH_ + +#include "MathTools.h" + +/*----------------------------------------------------------------------*\ + |* Declaration *| + \*---------------------------------------------------------------------*/ + +/*--------------------------------------*\ + |* Public *| + \*-------------------------------------*/ + +class Vague0Math + { + + /*--------------------------------------*\ + |* Constructor *| + \*-------------------------------------*/ + + public: + + __device__ Vague0Math(int w, int h) + { + this->factor = 4 * PI / (float) w; + } + + __device__ Vague0Math(const Vague0Math& 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: + + float factor; + + }; + +#endif + +/*----------------------------------------------------------------------*\ + |* End *| + \*---------------------------------------------------------------------*/