mirror of
https://github.com/opencv/opencv.git
synced 2025-06-07 17:44:04 +08:00
fixed bug: opencv read tif file convert Palette color image as grayscale image
This commit is contained in:
parent
9e6c290696
commit
af154e3053
@ -303,7 +303,12 @@ bool TiffDecoder::readHeader()
|
|||||||
result = true;
|
result = true;
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
m_type = CV_MAKETYPE(CV_8U, !isGrayScale ? wanted_channels : 1);
|
//Palette color, the value of the component is used as an index into the red,
|
||||||
|
//green and blue curves in the ColorMap field to retrieve an RGB triplet that defines the color.
|
||||||
|
if(photometric == PHOTOMETRIC_PALETTE)
|
||||||
|
m_type = CV_MAKETYPE(CV_8U, 3);
|
||||||
|
else
|
||||||
|
m_type = CV_MAKETYPE(CV_8U, !isGrayScale ? wanted_channels : 1);
|
||||||
result = true;
|
result = true;
|
||||||
break;
|
break;
|
||||||
case 16:
|
case 16:
|
||||||
|
@ -219,6 +219,16 @@ TEST(Imgcodecs_Tiff, readWrite_32FC3_RAW)
|
|||||||
EXPECT_EQ(0, remove(filenameOutput.c_str()));
|
EXPECT_EQ(0, remove(filenameOutput.c_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(Imgcodecs_Tiff, read_palette_color_image)
|
||||||
|
{
|
||||||
|
const string root = cvtest::TS::ptr()->get_data_path();
|
||||||
|
const string filenameInput = root + "readwrite/test_palette_color_image.tif";
|
||||||
|
|
||||||
|
const Mat img = cv::imread(filenameInput, IMREAD_UNCHANGED);
|
||||||
|
ASSERT_FALSE(img.empty());
|
||||||
|
ASSERT_EQ(CV_8UC3, img.type());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//==================================================================================================
|
//==================================================================================================
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user