/* right arrow to increase the gaussian delta left arrow to decrease the gaussian delta up arrow to increase the euclidean delta down arrow to decrease the euclidean delta */ void specialKey(int key, int x, int y) { switch(key) { case GLUT_KEY_RIGHT: euclidean_delta *= 1.5; break; case GLUT_KEY_LEFT: euclidean_delta /= 1.5; break; case GLUT_KEY_DOWN: if(gaussian_delta > 0.1) gaussian_delta /= 2; //updateGaussianGold(gaussian_delta, filter_radius); updateGaussian(gaussian_delta, filter_radius); break; case GLUT_KEY_UP: gaussian_delta *= 2; //updateGaussianGold(gaussian_delta, filter_radius); updateGaussian(gaussian_delta, filter_radius); break; default: break; } printf("gaussian delta = %.2f, euclidean delta = %.2f, iterations = %d\n", gaussian_delta, euclidean_delta, iterations); }
void initCuda() { //initialize gaussian mask updateGaussian(gaussian_delta, filter_radius); initTexture(width, height, hImage); sdkCreateTimer(&timer); sdkCreateTimer(&kernel_timer); }
void initCuda() { // allocate device memory cutilSafeCall( cudaMalloc( (void**) &d_img, (width * height * sizeof(unsigned int)) )); //initialize gaussian mask //updateGaussianGold(gaussian_delta, filter_radius); updateGaussian(gaussian_delta, filter_radius); initTexture(width, height, h_img); cutilCheckError( cutCreateTimer( &timer)); }
void runAutoTest(int argc, char **argv) { int devID = 0; shrLog("[runAutoTest]: [%s] (automated testing w/ readback)\n", sSDKsample); devID = cutilChooseCudaDevice(argc, argv); loadImageData(argc, argv); initCuda(); g_CheckRender = new CheckBackBuffer(width, height, 4, false); g_CheckRender->setExecPath(argv[0]); unsigned int *d_result; cutilSafeCall( cudaMalloc( (void **)&d_result, width*height*sizeof(unsigned int)) ); for(int i = 0; i < 4; i++) { shrLog("[AutoTest]: %s (radius=%d)", sSDKsample, filter_radius ); bilateralFilterRGBA(d_result, width, height, euclidean_delta, filter_radius, iterations, nthreads); // check if kernel execution generated an error cutilCheckMsg("Error: bilateralFilterRGBA Kernel execution FAILED"); cutilSafeCall( cutilDeviceSynchronize() ); cudaMemcpy(g_CheckRender->imageData(), d_result, width*height*sizeof(unsigned int), cudaMemcpyDeviceToHost); g_CheckRender->savePPM(sOriginal[i], false, NULL); if (!g_CheckRender->PPMvsPPM(sOriginal[i], sReference[i], MAX_EPSILON_ERROR, 0.15f)) { g_TotalErrors++; } gaussian_delta += 1.0f; euclidean_delta *= 1.25f; updateGaussian(gaussian_delta, filter_radius); } cutilSafeCall( cudaFree( d_result ) ); delete g_CheckRender; }
/* right arrow to increase the gaussian delta left arrow to decrease the gaussian delta up arrow to increase the euclidean delta down arrow to decrease the euclidean delta */ void keyboard(unsigned char key, int /*x*/, int /*y*/) { switch (key) { case 27: #if defined (__APPLE__) || defined(MACOSX) exit(EXIT_SUCCESS); #else glutDestroyWindow(glutGetWindow()); return; #endif break; case 'a': case 'A': g_bInteractive = !g_bInteractive; printf("> Animation is %s\n", !g_bInteractive ? "ON" : "OFF"); break; case ']': iterations++; break; case '[': iterations--; if (iterations < 1) { iterations = 1; } break; case '=': case '+': filter_radius++; if (filter_radius > MAX_FILTER_RADIUS) { filter_radius = MAX_FILTER_RADIUS; } updateGaussian(gaussian_delta, filter_radius); break; case '-': filter_radius--; if (filter_radius < 1) { filter_radius = 1; } updateGaussian(gaussian_delta, filter_radius); break; case 'E': euclidean_delta *= 1.5; break; case 'e': euclidean_delta /= 1.5; break; case 'g': if (gaussian_delta > 0.1) { gaussian_delta /= 2; } //updateGaussianGold(gaussian_delta, filter_radius); updateGaussian(gaussian_delta, filter_radius); break; case 'G': gaussian_delta *= 2; //updateGaussianGold(gaussian_delta, filter_radius); updateGaussian(gaussian_delta, filter_radius); break; default: break; } printf("filter radius = %d, iterations = %d, gaussian delta = %.2f, euclidean delta = %.2f\n", filter_radius, iterations, gaussian_delta, euclidean_delta); glutPostRedisplay(); }