Skip to content

GaussianBlur Performance Difference between OpenCV 3.3.0 and OpenCV 4.7.0 #24135

@christian1steinmetz

Description

@christian1steinmetz

System Information

OpenCV version: 4.7.0 and 3.3.0
Operating System / Platform: Windows 10
Compiler & compiler version: Visual Studio 2017

Detailed description

I recently upgraded an older software project that used to run using OpenCV 3.3.0 to the version of OpenCV that was then up-to-date (4.7.0). For some reason, somewhere inside the project, a grayscale image is blurred using the function GaussianBlur. Even though the input images and all parameters are similar, the output is very different between the output that is obtained from the 3.3.0-version and the 4.7.0-version.
I call the function as follows:

#include <opencv2/opencv.hpp>

int main()
{
cv::Mat img = cv::imread("<path>", IMREAD_GRAYSCALE);
cv::Mat blurred;
cv::resize(img , img , { 160, 90 });
cv::GaussianBlur(frame, blurred, {0, 0}, 7.5);
}

The result is different in almost every pixel, by usually less than 10, but always around 3-5 intensity steps. I tried to debug into OpenCV and found a completely new implementation using the OpenCV parallel_for_ in the newer version in contrast to a simpler hal::sepFilter2D in OCV 3.3.0, so it was hard to compare intermediate steps.

It seems highly suspicious and very unlogical for me, though, that the results for a fixed algorithm are this different between the two versions. I did not find anything mentioned in any of the release notes up to now stating that the old version of the Gaussian blur was wrong to some degree, so this leaves me very confused.

Does anyone have any insights? Imho, a software update should not change the quality of standard algorithms, at least not if it's not purely concerning speed.

[This is a question, but related to critical insights in the code, so I figured this is the better place to put it than in the forum where users are probably more present than contributors.]

Steps to reproduce

Generate two projects, one with OpenCV 3.3.0 and one with OpenCV 4.7.0 and use the same main-file (above). Look at the differences. e.g. with the help of Image Watch.

Issue submission checklist

  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
  • I updated to the latest OpenCV version and the issue is still there
  • There is reproducer code and related data files (videos, images, onnx, etc)

Metadata

Metadata

Assignees

No one assigned

    Labels

    incompletequestion (invalid tracker)ask questions and other "no action" items here: https://forum.opencv.org

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions