#include "Halide.h"
#include <stdio.h>
#include "halide_image_io.h"
using namespace Halide::Tools;
int main(int argc, char **argv) {
Var x(
"x"), y(
"y"), c(
"c");
{
Func input_16(
"input_16");
input_16(x, y, c) = cast<uint16_t>(input(x, y, c));
blur_x(x, y, c) = (input_16(x - 1, y, c) +
2 * input_16(x, y, c) +
input_16(x + 1, y, c)) / 4;
blur_y(x, y, c) = (blur_x(x, y - 1, c) +
2 * blur_x(x, y, c) +
blur_x(x, y + 1, c)) / 4;
output(x, y, c) = cast<uint8_t>(blur_y(x, y, c));
result.set_min(1, 1);
save_image(result, "blurry_parrot_1.png");
}
{
Expr clamped_x = clamp(x, 0, input.width() - 1);
Expr clamped_y = clamp(y, 0, input.height() - 1);
clamped(x, y, c) = input(clamped_x, clamped_y, c);
Func input_16(
"input_16");
input_16(x, y, c) = cast<uint16_t>(clamped(x, y, c));
blur_x(x, y, c) = (input_16(x - 1, y, c) +
2 * input_16(x, y, c) +
input_16(x + 1, y, c)) / 4;
blur_y(x, y, c) = (blur_x(x, y - 1, c) +
2 * blur_x(x, y, c) +
blur_x(x, y + 1, c)) / 4;
output(x, y, c) = cast<uint8_t>(blur_y(x, y, c));
save_image(result, "blurry_parrot_2.png");
}
printf("Success!\n");
return 0;
}
A Halide::Buffer is a named shared reference to a Halide::Runtime::Buffer.
Realization realize(std::vector< int32_t > sizes={}, const Target &target=Target())
Evaluate this function over some rectangular domain and return the resulting buffer or buffers.
A Halide variable, to be used when defining functions.
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
A fragment of Halide syntax.