Ask Your Question

filter2D and sepFilter2D, specifying the value for a constant border

asked 2012-07-12 17:25:06 -0500

LoopUniverse gravatar image

updated 2012-07-13 20:42:46 -0500

When calling filter2D and sepFilter2D, I want to use a constant border, which I do by providing BORDER_CONSTANT for the "borderType" parameter as specified in the documentation (

However, I do not see how I can specify WHAT I want that constant value to be. How do I achieve this?

(edit: I did find that the default constant border value seems to be 0.)

(edit in reply to Alexander, I do not see how to reply directly to answers: If I am not mistaken, copyMakeBorder will allocate a new image and copy the input image to a subregion of that new image. That seems a little excessive just to get access to the the ability to have non-zero constant border interpolation methods. Is there any other way to change the constant border value that does not require such memory allocations and copies?)

edit retag flag offensive close merge delete



Please use links to, because may be shut down at some point...

Kirill Kornyakov gravatar imageKirill Kornyakov ( 2012-07-13 01:59:28 -0500 )edit

The source for filter2D does a copyMakeBorder anyway, perhaps this is cheaper than doing a range check on every iteration as that would introduce branches? (i.e. If inside use the pixel value else use a constant value)

_Robert gravatar image_Robert ( 2014-09-18 15:40:39 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2012-07-12 17:37:47 -0500

AlexanderShishkov gravatar image

updated 2012-10-02 06:09:09 -0500

V.G. gravatar image

If you want to use BORDER_CONSTANT, you should manually add border to your image with copyMakeBorder) function (see tutorial)

edit flag offensive delete link more
Login/Signup to Answer

Question Tools


Asked: 2012-07-12 17:25:06 -0500

Seen: 3,751 times

Last updated: Oct 02 '12