reduce with CV_REDUCE_AVG does not work with 8U matrices (Bug #816)
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
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