mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 15:53:03 +04:00
Merge pull request #25280 from Kumataro:fix25274
imgcodecs: jpeg: re-support to read CMYK Jpeg #25280 Close #25274 OpenCV Extra: https://github.com/opencv/opencv_extra/pull/1163 ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
@@ -178,6 +178,44 @@ TEST(Imgcodecs_Jpeg, encode_decode_rst_jpeg)
|
||||
EXPECT_EQ(0, remove(output_normal.c_str()));
|
||||
}
|
||||
|
||||
// See https://github.com/opencv/opencv/issues/25274
|
||||
typedef testing::TestWithParam<int> Imgcodecs_Jpeg_decode_cmyk;
|
||||
TEST_P(Imgcodecs_Jpeg_decode_cmyk, regression25274)
|
||||
{
|
||||
const int imread_flag = GetParam();
|
||||
|
||||
/*
|
||||
* "test_1_c4.jpg" is CMYK-JPEG.
|
||||
* $ convert test_1_c3.jpg -colorspace CMYK test_1_c4.jpg
|
||||
* $ identify test_1_c4.jpg
|
||||
* test_1_c4.jpg JPEG 480x640 480x640+0+0 8-bit CMYK 11240B 0.000u 0:00.000
|
||||
*/
|
||||
|
||||
cvtest::TS& ts = *cvtest::TS::ptr();
|
||||
|
||||
string rgb_filename = string(ts.get_data_path()) + "readwrite/test_1_c3.jpg";
|
||||
cv::Mat rgb_img = cv::imread(rgb_filename, imread_flag);
|
||||
ASSERT_FALSE(rgb_img.empty());
|
||||
|
||||
string cmyk_filename = string(ts.get_data_path()) + "readwrite/test_1_c4.jpg";
|
||||
cv::Mat cmyk_img = cv::imread(cmyk_filename, imread_flag);
|
||||
ASSERT_FALSE(cmyk_img.empty());
|
||||
|
||||
EXPECT_EQ(rgb_img.size(), cmyk_img.size());
|
||||
EXPECT_EQ(rgb_img.type(), cmyk_img.type());
|
||||
|
||||
// Jpeg is lossy compression.
|
||||
// There may be small differences in decoding results by environments.
|
||||
// -> 255 * 1% = 2.55 .
|
||||
EXPECT_EQ(3, cvtest::norm(rgb_img, cmyk_img, NORM_INF));
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P( /* nothing */,
|
||||
Imgcodecs_Jpeg_decode_cmyk,
|
||||
testing::Values(cv::IMREAD_COLOR,
|
||||
cv::IMREAD_GRAYSCALE,
|
||||
cv::IMREAD_ANYCOLOR));
|
||||
|
||||
//==================================================================================================
|
||||
|
||||
static const uint32_t default_sampling_factor = static_cast<uint32_t>(0x221111);
|
||||
|
||||
Reference in New Issue
Block a user