4

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

The GaussianBlur call:

GaussianBlur(src, dest, Size(13,13), 1.5, BORDER_REPLICATE);

The EmguCV call:

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:

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 );
}

...which seems to be doing the same thing my original OpenCV call is doing. 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 also crossposted this question on the EmguCV forum.

Chris Marasti-Georg
  • 34,091
  • 15
  • 92
  • 137
  • 1
    Is the library you are linking your projects exactly the same? Maybe one of them is compiled to use GPU or streaming instructions and the other is executing completely in the CPU FP ALU, so there might be rounding errors that are more noticeable in the faster (and less accurate) implementations – fortran Nov 21 '11 at 15:46
  • @fortran From what I can tell with Process Explorer, both apps are loading the same 3 OpenCV DLLs and 1 TBB dll. – Chris Marasti-Georg Nov 21 '11 at 16:11

1 Answers1

2

The problem is that:

GaussianBlur(src, dest, Size(13,13), 1.5, BORDER_REPLICATE);

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

CvInvoke.cvSmooth(src, dst, SMOOTH_TYPE.CV_GAUSSIAN, 13, 13, 1.5, 1);

results in a perfect match.

Chris Marasti-Georg
  • 34,091
  • 15
  • 92
  • 137