1

I want to make to extend an input image symmetrically so that if the output image is 20 pixels wider and taller than the input then all 4 sides would have be extended by 10 pixels and the image would be mirrored.

I have tried using the mirror_image function from BoundaryConditions and passing an a Region that has the extents start at a negative minimum and extent of the output image. But instead of getting a symmetrically mirrored image it extends the right and bottom of the image with black pixels.

Is this possible with the standard Halide BoundaryConditions or does it have to be written manually?

Test code:

Range h_range = {Expr(0 - cast<int32_t>(left)), Expr(output.width())}; // left = the amount of pixels to extend to the left
Range v_range = {Expr(0 - cast<int32_t>(top)), Expr(output.height())}; // top = the amount of pixels to extend upwards
Range d_range = {Expr(0), Expr(output.channels())};
Region bounds = {h_range, v_range, d_range};

Func clamped;
clamped = Halide::BoundaryConditions::mirror_image(input, bounds);

0 Answers0