c++ - 无法在 Halide 中加载灰度图像

标签 c++ halide

尝试加载灰度图像png格式以执行此代码时出现错误。我的程序是Halide Tutorial类(class)2的一部分。这是我的代码:

    #include <stdio.h>
    #include "Halide.h"
    #include "halide_image_io.h"
    using namespace Halide;
    using namespace Halide::Tools;
    
    int main(int argc, char **argv) {
        Halide::Image<uint8_t> input = load_image(argv[1]);
        Halide::Func brighter;
        Halide::Var x, y, c;
        Halide::Expr value = input(x, y, c);
        value = Halide::cast<float>(value);
        value = value * 1.5f;
        value = Halide::min(value, 255.0f);
        value = Halide::cast<uint8_t>(value);
        brighter(x, y, c) = value;
        Halide::Image<uint8_t> output = brighter.realize(input.width(), input.height(), input.channels());
        save_image(output, "brighter.png");
        printf("Success!\n");
        return 0;
    }
这是错误消息:

Error:

3-argument call to "i0", which has 2 dimensions.

Aborted (core dumped)

最佳答案

Halide将灰度图像视为二维数组,因此您可以像这样访问它们:

input(x, y)

不像这样:
input(x, y, c)

关于c++ - 无法在 Halide 中加载灰度图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42347564/

相关文章:

c++ - 如何让Halide使用滑动窗口优化?

c++ - Qt 对于我的上限带宽来说太大了。我有什么选择?

c++ - 使用 Fortran 中的内存数据调用 C 代码

c++ - 预编译 boost 库包 (Ubuntu)

c++ - Halide 外部法

halide - Halide 索引是行优先、列优先还是混合?

c++ - 使用抽象类实现派生类的元素栈

c++ - 如何使用 C++ 打开 excel 查看器文件?

halide - 使用增强型生成器的双边网格生成器类

c++ - Halide:如何处理(重叠) block 中的图像?