diff --git a/modules/core/src/stat.cpp b/modules/core/src/stat.cpp
index b3e8b1737..307a68b25 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 6b848b3c5..ca19427c9 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 e441adaba..70040e535 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 04aec365e..642000b50 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();