From ce2f4c6a4d2af94d51fb4e70cf3ad6e85fb4060c Mon Sep 17 00:00:00 2001 From: Vadim Pisarevsky Date: Tue, 2 Aug 2011 12:55:05 +0000 Subject: [PATCH] propagated fix for EXR from 2.3 branch to trunk --- modules/core/src/stat.cpp | 7 ++++--- modules/highgui/src/grfmt_base.hpp | 2 +- modules/highgui/src/grfmt_exr.cpp | 9 +++++++++ modules/highgui/src/grfmt_exr.hpp | 1 + 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/modules/core/src/stat.cpp b/modules/core/src/stat.cpp index b3e8b1737a..307a68b250 100644 --- a/modules/core/src/stat.cpp +++ b/modules/core/src/stat.cpp @@ -736,9 +736,10 @@ void cv::minMaxIdx(InputArray _src, double* minVal, InputArray _mask) { Mat src = _src.getMat(), mask = _mask.getMat(); - int depth = src.depth(); + int depth = src.depth(), cn = src.channels(); - CV_Assert( src.channels() == 1 && (mask.empty() || mask.type() == CV_8U) ); + CV_Assert( (cn == 1 && (mask.empty() || mask.type() == CV_8U)) || + (cn >= 1 && mask.empty() && !minIdx && !maxIdx) ); MinMaxIdxFunc func = minmaxTab[depth]; CV_Assert( func != 0 ); @@ -752,7 +753,7 @@ void cv::minMaxIdx(InputArray _src, double* minVal, double dminval = DBL_MAX, dmaxval = -DBL_MAX; size_t startidx = 1; int *minval = &iminval, *maxval = &imaxval; - int planeSize = (int)it.size; + int planeSize = (int)it.size*cn; if( depth == CV_32F ) minval = (int*)&fminval, maxval = (int*)&fmaxval; diff --git a/modules/highgui/src/grfmt_base.hpp b/modules/highgui/src/grfmt_base.hpp index 6b848b3c50..ca19427c95 100644 --- a/modules/highgui/src/grfmt_base.hpp +++ b/modules/highgui/src/grfmt_base.hpp @@ -63,7 +63,7 @@ public: int width() const { return m_width; }; int height() const { return m_height; }; - int type() const { return m_type; }; + virtual int type() const { return m_type; }; virtual bool setSource( const string& filename ); virtual bool setSource( const Mat& buf ); diff --git a/modules/highgui/src/grfmt_exr.cpp b/modules/highgui/src/grfmt_exr.cpp index e441adaba3..70040e5358 100644 --- a/modules/highgui/src/grfmt_exr.cpp +++ b/modules/highgui/src/grfmt_exr.cpp @@ -96,6 +96,13 @@ void ExrDecoder::close() } } + +int ExrDecoder::type() const +{ + return CV_MAKETYPE((m_isfloat ? CV_32F : CV_32S), m_iscolor ? 3 : 1); +} + + bool ExrDecoder::readHeader() { bool result = false; @@ -174,7 +181,9 @@ bool ExrDecoder::readHeader() bool ExrDecoder::readData( Mat& img ) { + m_native_depth = CV_MAT_DEPTH(type()) == img.depth(); bool color = img.channels() > 1; + uchar* data = img.data; int step = img.step; bool justcopy = m_native_depth; diff --git a/modules/highgui/src/grfmt_exr.hpp b/modules/highgui/src/grfmt_exr.hpp index 04aec365ec..642000b502 100644 --- a/modules/highgui/src/grfmt_exr.hpp +++ b/modules/highgui/src/grfmt_exr.hpp @@ -66,6 +66,7 @@ public: ExrDecoder(); ~ExrDecoder(); + int type() const; bool readData( Mat& img ); bool readHeader(); void close();