mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 23:33:05 +04:00
imgproc: fixed imread with output image argument, minor refactoring, fixes in HDR
This commit is contained in:
@@ -93,10 +93,18 @@ bool HdrDecoder::readData(Mat& _img)
|
||||
RGBE_ReadPixels_RLE(file, const_cast<float*>(img.ptr<float>()), img.cols, img.rows);
|
||||
fclose(file); file = NULL;
|
||||
|
||||
if(_img.depth() == img.depth()) {
|
||||
img.convertTo(_img, _img.type());
|
||||
} else {
|
||||
img.convertTo(_img, _img.type(), 255);
|
||||
// NOTE: 'img' has type CV32FC3
|
||||
switch (_img.depth())
|
||||
{
|
||||
case CV_8U: img.convertTo(img, _img.depth(), 255); break;
|
||||
case CV_32F: break;
|
||||
default: CV_Error(Error::StsError, "Wrong expected image depth, allowed: CV_8U and CV_32F");
|
||||
}
|
||||
switch (_img.channels())
|
||||
{
|
||||
case 1: cvtColor(img, _img, COLOR_BGR2GRAY); break;
|
||||
case 3: img.copyTo(_img); break;
|
||||
default: CV_Error(Error::StsError, "Wrong expected image channels, allowed: 1 and 3");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user