GilLevi
GilLevi

Reputation: 2137

How to filter a single column mat with Gaussian in OpenCV

I have mat with only one column and 1600 rows. I want to filter it using a Gaussian.

I tried the following:

Mat AFilt=Mat(palm_contour.size(),1,CV_32F);
GaussianBlur(A,AFilt,cv::Size(20,1),3);

But I get the exact same values in AFilt (the filtered mat) and A. It looks like GaussianBlur has done nothing.

What's the problem here? How can I smooth a single-column mat with a Gaussian kernel?

I read about BaseColumnFilt, but haven't seen any usage examples so I'm not sure how to use them.

Any help given will be greatly appreciated as I don't have a clue.

I'm working with OpenCV 2.4.5 on windows 8 using Visual Studio 2012.

Thanks

Gil.

Upvotes: 0

Views: 2409

Answers (2)

morotspaj
morotspaj

Reputation: 1420

You have a single column but you are specifying the width of the gaussian to be big instead of specifying the height! OpenCV use row,col or x,y notation depending on the context. A general rule is whenever you use Point or Size, they behave like x,y and whenever the parameters are separate values they behave like row,col.

The kernel size should also be odd. If you specify the kernel size you can set sigma to zero to let OpenCV compute a suitable sigma value.

To conclude, this should work better:

GaussianBlur(A,AFilt,cv::Size(1,21),0);

Upvotes: 4

Rosa Gronchi
Rosa Gronchi

Reputation: 1911

The documentation og GaussianBlur says the kernel size must be odd, I would try using an odd size kernel and see if that makes any difference

Upvotes: 1

Related Questions