Skip to content

imgproc: fix bit-exact GaussianBlur() / sepFilter2D()#15855

Merged
alalek merged 3 commits intoopencv:3.4from
alalek:issue_9863
Nov 17, 2019
Merged

imgproc: fix bit-exact GaussianBlur() / sepFilter2D()#15855
alalek merged 3 commits intoopencv:3.4from
alalek:issue_9863

Conversation

@alalek
Copy link
Copy Markdown
Member

@alalek alalek commented Nov 6, 2019

Merge with contrib: opencv/opencv_contrib#2342
Merge with extra: opencv/opencv_extra#685

resolves #9863

  • avoid kernels with bad approximation
  • GaussiabBlur - apply error-diffusion approximation for kernel (8-bit fraction)

TODO:

  • fix test from main repository
  • fix tests from opencv_contrib

- avoid kernels with bad approximation
- GaussiabBlur - apply error-diffusion approximation for kernel (8-bit fraction)
@alalek
Copy link
Copy Markdown
Member Author

alalek commented Nov 17, 2019

👍

@alalek alalek merged commit f4d55d5 into opencv:3.4 Nov 17, 2019
This was referenced Nov 17, 2019
softdouble validation_sum = softdouble::zero();
for (size_t i = 0; i < kernel.size(); i++)
{
validation_sum += softdouble((double)kernel[i]);
Copy link
Copy Markdown

@netbrain netbrain Dec 17, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

error: conversion from ‘__gnu_cxx::__alloc_traits<std::allocator<cv::{anonymous}::ufixedpoint16> >::value_type {aka cv::{anonymous}::ufixedpoint16}’ to ‘double’ is ambiguous
         validation_sum += softdouble((double)kernel[i]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@netbrain , what is your platform/compiler?

@netbrain
Copy link
Copy Markdown

netbrain commented Dec 17, 2019 via email

@svobora
Copy link
Copy Markdown

svobora commented Jun 18, 2020

@alalek I do not think you full realize what you did by this fix. Now the speed of GaussianBlur depends on the ability to create a precise filter. That certainly works for small kernels, but not for large ones where the corner coefficients diminish. If the filter cannot be created to be precise, the blur fallbacks to float processing, which results in very high performance hit.

For CV_8U images, kernel_size > 10, and reasonable sigma, the createBitExactKernel_32S always returns false. Then fallback to CV_32F computing is processed. But some of us are more interested in performance, not the precision of computation. For example, on embedded devices the slowdown is about 10 fold.

Could you add an ignore flag to bitexact computation, such that the user may choose between precision (run CV_32S if possible, fallback to CV_32F) and performance (always run CV_32S version)? Right now we can propably bypass the issue by generating the kernels on our end and filtering directly. But it would be a nice feature to satisfy performance seekers.

@asmorkalov
Copy link
Copy Markdown
Contributor

@svobora Thanks for the issue report. Could you file bug about the problem as dedicated issue with this description and link to the patch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants