     float *imageR;
     float *imageG;
     float *imageB;
+    
+    float *d_imageR;
+    float *d_imageG;
+    float *d_imageB;
+    
+    
     float *distance;
 
 

    if(y >= height)
        return;

    float widthF = (float)width;
    float heightF = (float)heightF;

    float uvx = (tan(3.14159265 / 4.0)) * (2.0 * x - widthF) /  widthF;
    float uvy = (tan(3.14159265 / 4.0)) * ( heightF /  widthF) * (2.0 * y- heightF) /  heightF;
    uvxArr[(y*width)+x] = uvx;
    uvyArr[(y*width)+x] = uvy;
}


    blocksDs.x = 1+ (width/threadsDs.x);
    blocksDs.y = 1+ (height/threadsDs.y);
    getErrorCuda((downsample<<<blocksDs, threadsDs>>>(height, width, scale, rawR, rawG, rawB, d_imageR, d_imageG, d_imageB)));

    cudaDeviceSynchronize();

    cudaMemcpy(imageR, d_imageR, sizeof(float)*height*width, cudaMemcpyDefault);
    cudaMemcpy(imageG, d_imageG, sizeof(float)*height*width, cudaMemcpyDefault);
    cudaMemcpy(imageB, d_imageB, sizeof(float)*height*width, cudaMemcpyDefault);

    std::cout << "writing image" << std::endl;
    writeImageRGB("test.png", width,height, imageR,imageG,imageB, "output");
