Constraints: 1. Have a pointer to an image with margins of size (ImHeight,ImWidth) 2. Filter size (FH,FW) ; FH,FW are odd 3. ActualImageHeight = ImHeight-2*(FH/2); ActualImageWidth = ImWidth-2*(FW/2);
How To:
Modify the minimum coordinate of the image. You didn't state if you are using JIT or AOT, but here is a JIT implementation.
Halide::Image input( ImWidth + 2 * FW, ImHeight + 2 * FH ), output;
input.set_min( -FW, -FH );
Func f;
f(x,y) = ( input( x - FW, y - FH ) + input( x + FW - 1, y + FH - 1 ) ) / 2;
output = f.realize( ImWidth, ImHeight );
For AOT:
ImageParam
for input
.Param<int>
for ImWidth
and ImHeight
to have them be parameters to the AOT function.int
for ImWidth
and ImHeight
to have them be baked into the the AOT function.set_bounds
and set_stride
for all dimensions of input
and f.output_buffer()
. These take Expr
s so will accept ImWidth + 2 * FW
if ImWidth
is a Param<int>
.