bug in source code histogram.cpp (Feature #3108)


Added by li jian over 11 years ago. Updated over 11 years ago.


Status:Done Start date:2013-06-21
Priority:Low Due date:
Assignee:Victor Kocheganov % Done:

0%

Category:imgproc, video
Target version:3.0-alpha
Difficulty:Medium Pull request:https://github.com/Itseez/opencv/pull/1248

Description

Hello, It seems that there is a bug in the source file modules/imgproc/src/hitogram.cpp,
the line 2498 is as follows:
double b = v1;
But we think that it should be:
double b = v1 + v2;
Is that right? This problem can be found in the version 2.4.4 and 2.4.5.
Thank you very much.


Associated revisions

Revision 7409f21e
Added by Vadim Pisarevsky over 10 years ago

Merge pull request #3108 from LeszekSwirski:fix-gemm-buf-allocate-2.4

History

Updated by Kirill Kornyakov over 11 years ago

  • Tracker changed from Bug to Bugfix

Updated by Kirill Kornyakov over 11 years ago

  • Operating System set to Linux
  • HW Platform set to x86
  • Difficulty set to Easy

Updated by Kirill Kornyakov over 11 years ago

According to the formula here: http://docs.opencv.org/modules/imgproc/doc/histograms.html?highlight=hist#cv.CompareHist, I belive that the implementation is correct:

    if( method == CV_COMP_CHISQR )
    {
        for( node1 = cvInitSparseMatIterator( mat1, &iterator );
             node1 != 0; node1 = cvGetNextSparseNode( &iterator ))
        {
            double v1 = *(float*)CV_NODE_VAL(mat1,node1);
            uchar* node2_data = cvPtrND( mat2, CV_NODE_IDX(mat1,node1), 0, 0, &node1->hashval );
            double v2 = node2_data ? *(float*)node2_data : 0.f;
            double a = v1 - v2;
            double b = v1;
            if( fabs(b) > DBL_EPSILON )
                result += a*a/b;
        }
    }

Li, please explain why do you think that the code is buggy, otherwise this ticket will be cancelled.

  • Category set to samples
  • Status changed from Open to Incomplete

Updated by Sebastian Krämer over 11 years ago

This issue keeps popping up, see #1263, #2199. There's definitely two variants to Chi-square metric, depending on its intended purpose.

I started working on a patch where both versions coexist. It's clean and working but I failed to fix the accuracy/regression tests, so the pull request 484 (https://github.com/Itseez/opencv/pull/484) was closed.

It'd be great if you could pick up the work and create another pull request for master branch (it must be there because it changes API). Then it will be part of next big OpenCV release. At the moment, I really don't know when I get back to looking at the patch again. With a fresh look at it though, it might be fixed quickly.

  • Target version set to 3.0-alpha

Updated by Victor Kocheganov over 11 years ago

Thank you Li for submitting the ticket and thank you Sebastian for your Pull Request, we really appreciate it!

But unfortunately we have highly limited human resources at the moment and if there is a chance you can find an extra time (I hope it will take less time for you then for anybody else, since you have made almost all the work) to finish this PR that would be great!

Thank you in advance,
Victor.

  • Priority changed from Normal to Low
  • Category changed from samples to imgproc, video
  • Status changed from Incomplete to Open
  • Affected version changed from 2.4.5 (latest release) to branch 'master' (2.9)
  • Difficulty changed from Easy to Medium
  • Pull request set to https://github.com/Itseez/opencv/pull/484
  • Assignee set to Vadim Pisarevsky

Updated by Victor Kocheganov over 11 years ago

  • Pull request changed from https://github.com/Itseez/opencv/pull/484 to https://github.com/Itseez/opencv/pull/1248
  • Tracker changed from Bugfix to Feature

Updated by Sebastian Krämer over 11 years ago

The latest pull request was successful, so I think this ticket can be closed.

Updated by Vladislav Vinogradov over 11 years ago

  • Assignee changed from Vadim Pisarevsky to Victor Kocheganov
  • Status changed from Open to Done

Also available in: Atom PDF