我试着用开放图像去噪。下面是代码:
int main() {
int width, height, nrChannels;
unsigned char* image = stbi_load("img_cornell_box.png", &width, &height, &nrChannels, 0);
unsigned char* resultImage = new unsigned char[width*height*nrChannels];
oidn::DeviceRef device = oidn::newDevice();
device.commit();
std::cout << nrChannels << std::endl;
oidn::FilterRef filter = device.newFilter("RT");
filter.setImage("color", image, oidn::Format::Float4, width, height);
filter.setImage("output", resultImage, oidn::Format::Float4, width, height);
filter.set("hdr", false);
filter.set("srgb", true);
filter.commit();
filter.execute();
const char* errorMessage;
if (device.getError(errorMessage) != oidn::Error::None) {
std::cout << "Error: " << errorMessage << std::endl;
}
else {
stbi_write_png("img.png", width, height, nrChannels, resultImage, width * nrChannels);
}
}我收到一个错误,说图像格式是不支持的。
如果我使用jpg,并将格式::Float4 4更改为格式::Float4 3,则会得到以下错误:
Exception thrown at 0x00007FFC5588E1F5 (OpenImageDenoise.dll) in oidntest.exe: 0xC0000005: Access violation reading location 0x0000021D9C42FA70.我做错什么了吗?这是我正在使用的图像:https://drive.google.com/open?id=1uSjsyWCRisXNFUJG6R8iL5AdVbM7_18u
发布于 2019-12-15 06:15:32
据我所知,您需要在浮点数数组中输入数据。现在,您的输入是无符号字符数组。要快速检查这一点,请尝试加载浮点数数组中的任何HDR映像并将其传递给setImage函数,这似乎是可行的。
在您的示例中,您需要读取单个图像通道数据并将其转换为浮动数据。如果图像颜色存储在0-255范围内,则需要将其带到0-1范围(不完全确定此阶段!)&然后将浮点数数组中的数据传递给去噪函数。
希望这能有所帮助。
https://computergraphics.stackexchange.com/questions/9418
复制相似问题