首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用开放图像去噪的困难

使用开放图像去噪的困难
EN

Computer Graphics用户
提问于 2019-12-11 21:47:13
回答 1查看 284关注 0票数 0

我试着用开放图像去噪。下面是代码:

代码语言:javascript
复制
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,则会得到以下错误:

代码语言:javascript
复制
Exception thrown at 0x00007FFC5588E1F5 (OpenImageDenoise.dll) in oidntest.exe: 0xC0000005: Access violation reading location 0x0000021D9C42FA70.

我做错什么了吗?这是我正在使用的图像:https://drive.google.com/open?id=1uSjsyWCRisXNFUJG6R8iL5AdVbM7_18u

EN

回答 1

Computer Graphics用户

回答已采纳

发布于 2019-12-15 06:15:32

据我所知,您需要在浮点数数组中输入数据。现在,您的输入是无符号字符数组。要快速检查这一点,请尝试加载浮点数数组中的任何HDR映像并将其传递给setImage函数,这似乎是可行的。

在您的示例中,您需要读取单个图像通道数据并将其转换为浮动数据。如果图像颜色存储在0-255范围内,则需要将其带到0-1范围(不完全确定此阶段!)&然后将浮点数数组中的数据传递给去噪函数。

希望这能有所帮助。

票数 0
EN
页面原文内容由Computer Graphics提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://computergraphics.stackexchange.com/questions/9418

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档