Ask Your Question
2

filter2D and sepFilter2D, specifying the value for a constant border

asked Jul 12 '12

LoopUniverse gravatar image

updated Jul 14 '12

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?)

Preview: (hide)

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 (Jul 13 '12)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 (Sep 18 '14)edit

1 answer

Sort by » oldest newest most voted
1

answered Jul 12 '12

AlexanderShishkov gravatar image

updated Oct 2 '12

V.G. gravatar image

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

Preview: (hide)

Question Tools

Stats

Asked: Jul 12 '12

Seen: 7,504 times

Last updated: Oct 02 '12