1
0
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:
Maksim Shabunin
2024-06-04 14:44:39 +03:00
parent 2624929ec6
commit b77c74b6fc
4 changed files with 72 additions and 83 deletions
+12 -4
View File
@@ -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;
}