Possible documentation error: minMaxIdx() on single-column matrix (Bug #2081)
Description
I noticed there is a difference in the results from minMaxIdx() going from OpenCV 2.2 to OpenCV 2.4.1.
I have a single-column-matrix 1x32. I call minMaxIdx() to retrieve the max-idx with a 'int maxBin[2] array.
OpenCV 2.2: the result is (0, 12)
OpenCV 2.4.1: the result is (12, 0)
According to the minMaxIdx() documentation, I should expect (0, 12); But if the ofs2Idx() performs according to the indexing convention of Mat class. I should expect (12, 0) because matrix element indexing begins with higher-dimension (rows).
Could you help clarify this?
Thanks!
Associated revisions
added check for false bug report #2081
fixed typo in minMaxIdx description (ticket #2081)
Merge pull request #2081 from ilya-lavrenov:tapi_perf
History
Updated by Vadim Pisarevsky over 12 years ago
It works properly. 1x32 is single-row, not single-column.
Here is the test code
Mat A(1, 32, CV_32F), B; for( int i = 0; i < A.cols; i++ ) A.at<float>(i) = (float)(i <= 12 ? i : 24 - i); transpose(A, B); int minidx[2] = {0, 0}, maxidx[2] = {0, 0}; double minval = 0, maxval = 0; minMaxIdx(A, &minval, &maxval, minidx, maxidx); CV_Assert(minidx[0] == 0 && minidx[1] == 31 && maxidx[0] == 0 && maxidx[1] == 12 && minval == -7 && maxval == 12); minMaxIdx(B, &minval, &maxval, minidx, maxidx); CV_Assert(minidx[0] == 31 && minidx[1] == 0 && maxidx[0] == 12 && maxidx[1] == 0 && minval == -7 && maxval == 12);
- Status changed from Open to Cancelled
Updated by Frankie Fong over 12 years ago
Thanks for clarifying. What I am saying is it is changed since OpenCV 2.2. And the documentation is not updated. Quoting here:
..., i.e. single-row matrix is Mx1 matrix (and therefore minIdx/maxIdx will be (i1,0)/(i2,0)) and single-column matrix is 1xN matrix (and therefore minIdx/maxIdx will be (0,j1)/(0,j2)).....
Updated by Andrey Kamaev over 12 years ago
- Target version set to 2.4.2
Updated by Vadim Pisarevsky over 12 years ago
thanks! it was obviously a bug in documentation: "single-column" and "single-row" should be exchanged. It was fixed in r8898
Updated by Andrey Kamaev over 12 years ago
- Status changed from Cancelled to Done