reduce with CV_REDUCE_AVG does not work with 8U matrices (Bug #816)


Added by Jesus Nuevo-Chiquero about 14 years ago. Updated almost 13 years ago.


Status:Done Start date:
Priority:Normal Due date:
Assignee:Vadim Pisarevsky % Done:

0%

Category:core
Target version:-
Affected version: Operating System:
Difficulty: HW Platform:
Pull request:

Description

In core/src/matrix.cpp (cv::reduce):

if( op == CV_REDUCE_AVG )
    {
        op = CV_REDUCE_SUM;
        if( sdepth < CV_32S && ddepth < CV_32S )
            temp.create(dst.rows, dst.cols, CV_32SC(src.channels()));
    }


should be:
if( op == CV_REDUCE_AVG )
    {
        op = CV_REDUCE_SUM;
        if( sdepth < CV_32S && ddepth < CV_32S ){
            temp.create(dst.rows, dst.cols, CV_32SC(src.channels()));
            ddepth=CV_32S;
        }
    }


otherwise when computing the mean of 8U matrices, ddepth is 8U even though temp is 32S, and no valid function is found. This appears in OpenCV 2.1 and 2.2 at least.

Associated revisions

Revision 6de72ea8
Added by Vadim Pisarevsky almost 14 years ago

resolved tickets #904 (nicer floating-point formatting) and #816 (reduce with CV_REDUCE_AVG on 8-bit arrays)

History

Updated by Vadim Pisarevsky almost 14 years ago

thanks! fixed in trunk

  • Status changed from Open to Done
  • (deleted custom field) set to fixed

Updated by Robert Pollak almost 13 years ago

For the record, the real fix was revision r5301.

What would be a workaround, e.g. for the CV_8U matrices returned by inRange?

Updated by Kirill Kornyakov almost 13 years ago

  • Description changed from In core/src/matrix.cpp (cv::reduce): if( op == CV_REDUCE_AVG ) { ... to In core/src/matrix.cpp (cv::reduce): <pre> if( op == CV_REDUCE_AVG ) ... More

Also available in: Atom PDF