nmud
nmud

Reputation: 175

OpenCV border mode issue with blur filter

I've been stuck on this for a few days now, maybe someone will be able to help me here.

I'm using OpenCV C++ API to perform some basic image processing. I have a step where I want to blur my image and specify BORDER_WRAPas my border type :

cv::blur(img, img, cv::Size(3, 3), cv::Point(-1, -1), cv::BORDER_WRAP);

But when executing my code, I get the following error:

OpenCV Error: Assertion failed (columnBorderType != BORDER_WRAP)

However, everything works fine when I use other border types, (BORDER_REFLECT for example), but I need BORDER_WRAP

Things seem to work if I use copyMakeBorder(img, img, 1, 1, 1, 1, cv::BORDER_WRAP) first on my image, blur this new image and then crop it back to the size of the original one, but still I can't figure out why my first try doesn't work.

Anyone knows how I can solve this ?

Upvotes: 2

Views: 2420

Answers (1)

Marinos K
Marinos K

Reputation: 1819

You can't do this. BORDER_WRAP is not accepted by all functions - it's valid just for a few of them and, as the assertion failure confirms, cv::blur is not one of them..

But as you've already found out yourself, you can first use cv::copyMakeBorder, blur this new image and crop it back to the size of the original.

Upvotes: 3

Related Questions