propagated fix for EXR from 2.3 branch to trunk

This commit is contained in:
Vadim Pisarevsky 2011-08-02 12:55:05 +00:00
parent f0b3cb1845
commit ce2f4c6a4d
4 changed files with 15 additions and 4 deletions

View File

@ -736,9 +736,10 @@ void cv::minMaxIdx(InputArray _src, double* minVal,
InputArray _mask) InputArray _mask)
{ {
Mat src = _src.getMat(), mask = _mask.getMat(); 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]; MinMaxIdxFunc func = minmaxTab[depth];
CV_Assert( func != 0 ); CV_Assert( func != 0 );
@ -752,7 +753,7 @@ void cv::minMaxIdx(InputArray _src, double* minVal,
double dminval = DBL_MAX, dmaxval = -DBL_MAX; double dminval = DBL_MAX, dmaxval = -DBL_MAX;
size_t startidx = 1; size_t startidx = 1;
int *minval = &iminval, *maxval = &imaxval; int *minval = &iminval, *maxval = &imaxval;
int planeSize = (int)it.size; int planeSize = (int)it.size*cn;
if( depth == CV_32F ) if( depth == CV_32F )
minval = (int*)&fminval, maxval = (int*)&fmaxval; minval = (int*)&fminval, maxval = (int*)&fmaxval;

View File

@ -63,7 +63,7 @@ public:
int width() const { return m_width; }; int width() const { return m_width; };
int height() const { return m_height; }; 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 string& filename );
virtual bool setSource( const Mat& buf ); virtual bool setSource( const Mat& buf );

View File

@ -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 ExrDecoder::readHeader()
{ {
bool result = false; bool result = false;
@ -174,7 +181,9 @@ bool ExrDecoder::readHeader()
bool ExrDecoder::readData( Mat& img ) bool ExrDecoder::readData( Mat& img )
{ {
m_native_depth = CV_MAT_DEPTH(type()) == img.depth();
bool color = img.channels() > 1; bool color = img.channels() > 1;
uchar* data = img.data; uchar* data = img.data;
int step = img.step; int step = img.step;
bool justcopy = m_native_depth; bool justcopy = m_native_depth;

View File

@ -66,6 +66,7 @@ public:
ExrDecoder(); ExrDecoder();
~ExrDecoder(); ~ExrDecoder();
int type() const;
bool readData( Mat& img ); bool readData( Mat& img );
bool readHeader(); bool readHeader();
void close(); void close();