mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 07:43:03 +04:00
Merge pull request #27226 from Kumataro:fix27225
imgproc: cvtColor: remove to copy edge pixels for COLOR_Bayer*_VNGs. #27226 Close https://github.com/opencv/opencv/issues/27225 Close https://github.com/opencv/opencv/issues/5089 Related https://github.com/opencv/opencv_extra/pull/1249 ### 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. - [ ] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
@@ -1905,6 +1905,64 @@ TEST(Imgproc_ColorBayerVNG, regression)
|
||||
}
|
||||
}
|
||||
|
||||
// See https://github.com/opencv/opencv/issues/5089
|
||||
// See https://github.com/opencv/opencv/issues/27225
|
||||
typedef tuple<cv::ColorConversionCodes, cv::ColorConversionCodes> VNGandINT;
|
||||
typedef testing::TestWithParam<VNGandINT> Imgproc_ColorBayerVNG_Codes;
|
||||
|
||||
TEST_P(Imgproc_ColorBayerVNG_Codes, regression27225)
|
||||
{
|
||||
const cv::ColorConversionCodes codeVNG = get<0>(GetParam());
|
||||
const int margin = (codeVNG == cv::COLOR_BayerGB2BGR_VNG || codeVNG == cv::COLOR_BayerGR2BGR_VNG)? 5 : 4;
|
||||
|
||||
cv::Mat in = cv::Mat::eye(16, 16, CV_8UC1) * 255;
|
||||
cv::resize(in, in, {}, 2, 2, cv::INTER_NEAREST);
|
||||
|
||||
cv::Mat out;
|
||||
EXPECT_NO_THROW(cv::cvtColor(in, out, codeVNG));
|
||||
|
||||
for(int iy=0; iy < out.size().height; iy++) {
|
||||
for(int ix=0; ix < out.size().width; ix++) {
|
||||
// Avoid to test around main diagonal pixels.
|
||||
if(cv::abs(ix - iy) < margin) {
|
||||
continue;
|
||||
}
|
||||
// Others should be completely black.
|
||||
const Vec3b pixel = out.at<Vec3b>(iy, ix);
|
||||
EXPECT_EQ(pixel[0], 0) << cv::format(" - iy = %d, ix = %d", iy, ix);
|
||||
EXPECT_EQ(pixel[1], 0) << cv::format(" - iy = %d, ix = %d", iy, ix);
|
||||
EXPECT_EQ(pixel[2], 0) << cv::format(" - iy = %d, ix = %d", iy, ix);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_P(Imgproc_ColorBayerVNG_Codes, regression27225_small)
|
||||
{
|
||||
// for too small images use the simple interpolation algorithm
|
||||
const cv::ColorConversionCodes codeVNG = get<0>(GetParam());
|
||||
const cv::ColorConversionCodes codeINT = get<1>(GetParam());
|
||||
cv::Mat in = cv::Mat::eye(7, 7, CV_8UC1) * 255;
|
||||
|
||||
cv::Mat outVNG;
|
||||
EXPECT_NO_THROW(cv::cvtColor(in, outVNG, codeVNG));
|
||||
cv::Mat outINT;
|
||||
EXPECT_NO_THROW(cv::cvtColor(in, outINT, codeINT));
|
||||
|
||||
Mat diff;
|
||||
absdiff(outVNG, outINT, diff);
|
||||
|
||||
imwrite("outVNG.png", outVNG);
|
||||
imwrite("outINT.png", outINT);
|
||||
EXPECT_EQ(0, countNonZero(diff.reshape(1) > 1));
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(/**/, Imgproc_ColorBayerVNG_Codes,
|
||||
testing::Values(
|
||||
make_tuple(cv::COLOR_BayerBG2BGR_VNG, cv::COLOR_BayerBG2BGR),
|
||||
make_tuple(cv::COLOR_BayerGB2BGR_VNG, cv::COLOR_BayerGB2BGR),
|
||||
make_tuple(cv::COLOR_BayerRG2BGR_VNG, cv::COLOR_BayerRG2BGR),
|
||||
make_tuple(cv::COLOR_BayerGR2BGR_VNG, cv::COLOR_BayerGR2BGR)));
|
||||
|
||||
// creating Bayer pattern
|
||||
template <typename T, int depth>
|
||||
static void calculateBayerPattern(const Mat& src, Mat& bayer, const char* pattern)
|
||||
|
||||
Reference in New Issue
Block a user