Gaussian Blur mismatch

Ask question on using Emgu CV with C#

Gaussian Blur mismatch

Postby cgeorg » Mon Nov 21, 2011 10:27 am

I'm experiencing a mismatch between the OpenCV GaussianBlur function and the EmguCv CvInvoke.cvSmooth/Image.SmoothGaussian functions.

The GaussianBlur call:

Code: Select all
GaussianBlur(src, dest, Size(13,13), 1.5, BORDER_REPLICATE);


The EmguCV call:

Code: Select all
CvInvoke.cvSmooth(src, dst, SMOOTH_TYPE.CV_GAUSSIAN, 13, 13, 1.5, 0);


In both cases, src is a 32F, 3 channel image. I have verified that the contents of src are identical (saved them as bmp and did binary diff).

The cvSmooth call in opencv looks like this:

Code: Select all
CV_IMPL void
cvSmooth( const void* srcarr, void* dstarr, int smooth_type,
          int param1, int param2, double param3, double param4 )
{
    cv::Mat src = cv::cvarrToMat(srcarr), dst0 = cv::cvarrToMat(dstarr), dst = dst0;

    if( smooth_type == CV_GAUSSIAN )
        cv::GaussianBlur( src, dst, cv::Size(param1, param2), param3, param4, cv::BORDER_REPLICATE );
}


CV_GAUSSIAN is defined as 2 in both EmguCV and opencv. The results end up very close, but the EmguCV image comes out a little bit blurrier than the opencv image. Any ideas? I crossposted this to StackOverflow as well.
cgeorg
 
Posts: 7
Joined: Fri Nov 11, 2011 11:33 am

Re: Gaussian Blur mismatch

Postby cgeorg » Mon Nov 21, 2011 2:42 pm

The problem is that:

Code: Select all
GaussianBlur(src, dest, Size(13,13), 1.5, BORDER_REPLICATE);

Is passing 1.5 as sigma1, and 1 (BORDER_REPLICATE) as sigma2. Changing the EmguCV code to

Code: Select all
CvInvoke.cvSmooth(src, dst, SMOOTH_TYPE.CV_GAUSSIAN, 13, 13, 1.5, 1);

results in a perfect match.
cgeorg
 
Posts: 7
Joined: Fri Nov 11, 2011 11:33 am


Return to C# Help

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 7 guests