Ask Your Question
2

filter2D and sepFilter2D, specifying the value for a constant border

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

LoopUniverse gravatar image

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

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 (http://docs.opencv.org/modules/imgproc/doc/filtering.html?highlight=gaussianblur#filter2d).

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

Comments

1

Please use links to docs.opencv.org, because opencv.itseez.com may be shut down at some point...

Kirill Kornyakov gravatar imageKirill Kornyakov ( 2012-07-13 01:59:28 -0600 )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) https://github.com/Itseez/opencv/blob/5f590ebed084a5002c9013e11c519dcb139d47e9/modules/ts/src/ts_func.cpp#L787

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

1 answer

Sort by ยป oldest newest most voted
1

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

AlexanderShishkov gravatar image

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

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

Question Tools

Stats

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

Seen: 7,321 times

Last updated: Oct 02 '12