1

I get an error when I tried to load an grayscale image png format for executing this code. My program is a part from Halide Tutorial lesson 2. This is my code:

    #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;
    }

And this is the error message:

Error:

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

Aborted (core dumped)

1 Answer 1

1

Halide treats grayscale images as two-dimensional arrays, so you access them like this:

input(x, y)

not like this:

input(x, y, c)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.