bug in cv::blur (Bug #3345)


Added by Ilya Lavrenov over 11 years ago. Updated about 11 years ago.


Status:Done Start date:2013-10-25
Priority:Normal Due date:
Assignee:- % Done:

0%

Category:imgproc, video
Target version:2.4.9
Affected version:branch '2.4' (2.4-dev) Operating System:Any
Difficulty:Medium HW Platform:Any
Pull request:https://github.com/Itseez/opencv/pull/2097

Description

Test:

TEST(Blur, Mat)
{
    Size kernelSize(3, 3);

    /// ksize > src_roi.size()
    Mat src(3, 3, CV_8UC1, cv::Scalar::all(255)), dst;
    Mat src_roi = src(Rect(1, 1, 1, 1));
    src_roi.setTo(cv::Scalar::all(0));

    blur(src_roi, dst, kernelSize, Point(-1, -1), BORDER_REPLICATE);
    std::cout << "ksize > src_roi.size() (works like BORDER_ISOLATED - why????? ):\n";
    std::cout << "src: " << std::endl << src << std::endl;
    std::cout << "src_roi: " << std::endl << src_roi << std::endl;
    std::cout << "dst: " << std::endl << dst << std::endl;

    /// ksize <= src_roi.size()
    src = Mat(5, 5, CV_8UC1, cv::Scalar(255));
    src_roi = src(Rect(1, 1, 3, 3));
    src_roi.setTo(0);
    src.at<uchar>(2, 2) = 255;

    blur(src_roi, dst, kernelSize, Point(-1, -1), BORDER_REPLICATE);
    std::cout << "\nksize <= src_roi.size() (works like !BORDER_ISOLATED - default behavior):\n";
    std::cout << "src: " << std::endl << src << std::endl;
    std::cout << "src_roi: " << std::endl << src_roi << std::endl;
    std::cout << "dst: " << std::endl << dst << std::endl;
}

Output:

ksize > src_roi.size() (works like BORDER_ISOLATED - why???? ):
src: 
[255, 255, 255;
  255, 0, 255;
  255, 255, 255]
src_roi: 
[0]
dst: 
[0]

ksize <= src_roi.size() (works like !BORDER_ISOLATED - default behavior):
src: 
[255, 255, 255, 255, 255;
  255, 0, 0, 0, 255;
  255, 0, 255, 0, 255;
  255, 0, 0, 0, 255;
  255, 255, 255, 255, 255]
src_roi: 
[0, 0, 0;
  0, 255, 0;
  0, 0, 0]
dst: 
[170, 113, 170;
  113, 28, 113;
  170, 113, 170]

but in the first case dst must be [227]


Associated revisions

Revision eb9d7c4d
Added by Seunghoon Park about 11 years ago

fixing bug #3345. use norm to make sure two matrices are the same.

Revision 78687330
Added by Seunghoon Park about 11 years ago

fixing bug #3345
(cherry picked from commit b036fc756a65c8be5b9b0e4d77d94b6f8099fc20)

Revision 27a8bb47
Added by Seunghoon Park about 11 years ago

fixing bug #3345. don't use BORDER_ISOLATED alone. it should be combined with some border type
(cherry picked from commit 2272a5876972f74684c43f2069c3046bd2888d01)

Revision 2c7cf52e
Added by Seunghoon Park about 11 years ago

fixing bug #3345. use norm to make sure two matrices are the same.
(cherry picked from commit eb9d7c4dd54eea87950d98b843b349db7a95c951)

Revision e4418e18
Added by Vadim Pisarevsky over 10 years ago

Merge pull request #3345 from D-Alex:master

History

Updated by Dmitry Retinskiy over 11 years ago

  • Assignee deleted (Vadim Pisarevsky)

Updated by Dmitry Retinskiy over 11 years ago

  • Status changed from New to Open

Updated by Alexander Smorkalov about 11 years ago

  • Target version changed from 2.4.8 to 2.4.9

Updated by Vladislav Vinogradov about 11 years ago

The pull request was merged into 2.4 branch.

Seunghoon Park, thank you very much for your contribution!

  • Status changed from Open to Done
  • Pull request set to https://github.com/Itseez/opencv/pull/2097

Also available in: Atom PDF