Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- __global__ void ApplyBlur(double *image_d1, double *kernel, double *output, int width, int height, int kernelSize, int totalThreads)
- {
- int id = blockDim.x * blockIdx.x + threadIdx.x;
-
- int filterHeight = kernelSize;
- int filterWidth = kernelSize;
- int newImageHeight = height-kernelSize+1;
- //int newImageHeight = height;
- int newImageWidth = width-kernelSize+1;
- int d,i,j,h,w;
- int fromY = (newImageHeight / totalThreads)*id;
- int toY = id != totalThreads-1 ? fromY + (newImageHeight / totalThreads) : newImageHeight;
- int fromX = (newImageWidth / totalThreads)*id;
- int toX = id != totalThreads-1 ? fromX + (newImageWidth / totalThreads) : newImageWidth;
- int numElements = sizeof(double) * 4 * newImageHeight * newImageWidth;
- for (i=0; i<newImageHeight ; i++) {
- for (j=fromX ; j<toX ; j++) {
- for(int k=0; k<4; k++){
- output[i*newImageWidth*4 + j*4 + k] = 0;
- for (h=i ; h<i+filterHeight ; h++) {
- for (w=j ; w<j+filterWidth ; w++) {
- output[i*newImageWidth*4 + j*4 + k] += kernel[(h-i) * kernelSize + (w-j)]*image_d1[h*width*4 + w*4 + k];
- }
- }
- }
- }
- }
- printf("");
- }
- ```
- I would really appreciate any help and thank you for taking the time to read my question.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement