RenderKit / oidn

Intel® Open Image Denoise library
https://www.openimagedenoise.org/
Apache License 2.0
1.74k stars 160 forks source link

Having issues Executing filters #147

Closed ludovicb1239 closed 1 year ago

ludovicb1239 commented 1 year ago

Hi, It's my first time using this library and it fits my application perfectly. My program is in C. I read the documentation and tried to understand most of it. But the error is output image not specified and I don't understand it. Is it possible to have help ? A few code snippets would go a big way !

` FILE fp_in = fopen("render.bmp", "rb"); unsigned char data = (unsigned char)malloc(width height 3 sizeof(char)); fread(data, sizeof(char), width height 3, fp_in); //Read the BMP header and check for compatibility char header[54]; fread(header, sizeof(char), 54, fp_in);

// Create an Intel Open Image Denoise device
OIDNDevice device = oidnNewDevice(OIDN_DEVICE_TYPE_DEFAULT);
oidnCommitDevice(device);

unsigned char* outData = (unsigned char*)malloc(width * height * 3 * sizeof(char));

// Create a filter for denoising a beauty (color) image using optional auxiliary images too
OIDNFilter filter = oidnNewFilter(device, "RT"); // generic ray tracing filte

oidnSetSharedFilterImage(filter, "color", data , OIDN_FORMAT_FLOAT3, width, height, 0, 0, 0);
oidnCommitFilter(filter);

// Filter the image
oidnExecuteFilter(filter);

// Check for errors
const char* errorMessage;
if (oidnGetDeviceError(device, &errorMessage) != OIDN_ERROR_NONE)
  printf("Error: %s\n", errorMessage);

FILE* fp_out = fopen("denoised.bmp", "wb");
//free(file_name);

//Write the BMP header to the output file
fwrite(header, sizeof(char), 54, fp_out);

//Write the denoised data to the output file
fwrite(outData, sizeof(char), width * height * 3, fp_out);

//Clean up
free(outData);
fclose(fp_out);

// Cleanup
oidnReleaseFilter(filter);
oidnReleaseDevice(device);`
atafra commented 1 year ago

Please read the documentation. You need to specify an output image too, not just the input.