Skip to content

Commit 62ee92e

Browse files
committed
ColorLab_full test fixed
1 parent 375ec5e commit 62ee92e

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

modules/imgproc/test/test_color.cpp

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2297,7 +2297,7 @@ static void validateResult(const Mat& reference, const Mat& actual, const Mat& s
22972297
ssize.width *= cn;
22982298
bool next = true;
22992299
//RGB2Lab_f works throug LUT and brings additional error
2300-
static const float maxErr = 1.f/200.f;
2300+
static const float maxErr = 1.f/192.f;
23012301

23022302
for (int y = 0; y < ssize.height && next; ++y)
23032303
{
@@ -2335,20 +2335,22 @@ TEST(Imgproc_ColorLab_Full, accuracy)
23352335
Size ssize = src.size();
23362336
CV_Assert(ssize.width == ssize.height);
23372337

2338-
RNG& rng = cvtest::TS::ptr()->get_rng();
2339-
int blueInd = rng.uniform(0., 1.) > 0.5 ? 0 : 2;
2340-
bool srgb = rng.uniform(0., 1.) > 0.5;
2341-
2342-
// Convert test image to LAB
2343-
cv::Mat lab;
2344-
int forward_code = blueInd ? srgb ? CV_BGR2Lab : CV_LBGR2Lab : srgb ? CV_RGB2Lab : CV_LRGB2Lab;
2345-
int inverse_code = blueInd ? srgb ? CV_Lab2BGR : CV_Lab2LBGR : srgb ? CV_Lab2RGB : CV_Lab2LRGB;
2346-
cv::cvtColor(src, lab, forward_code);
2347-
// Convert LAB image back to BGR(RGB)
2348-
cv::Mat recons;
2349-
cv::cvtColor(lab, recons, inverse_code);
2350-
2351-
validateResult(src, recons, src, forward_code);
2338+
for(int i = 0; i < 4; i++)
2339+
{
2340+
int blueInd = (i%2) > 0 ? 0 : 2;
2341+
bool srgb = i > 1;
2342+
2343+
// Convert test image to LAB
2344+
cv::Mat lab;
2345+
int forward_code = blueInd ? srgb ? CV_BGR2Lab : CV_LBGR2Lab : srgb ? CV_RGB2Lab : CV_LRGB2Lab;
2346+
int inverse_code = blueInd ? srgb ? CV_Lab2BGR : CV_Lab2LBGR : srgb ? CV_Lab2RGB : CV_Lab2LRGB;
2347+
cv::cvtColor(src, lab, forward_code);
2348+
// Convert LAB image back to BGR(RGB)
2349+
cv::Mat recons;
2350+
cv::cvtColor(lab, recons, inverse_code);
2351+
2352+
validateResult(src, recons, src, forward_code);
2353+
}
23522354
}
23532355

23542356
static void test_Bayer2RGB_EdgeAware_8u(const Mat& src, Mat& dst, int code)

modules/imgproc/test/test_precomp.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "opencv2/core/private.hpp"
1515
#include "opencv2/imgproc.hpp"
1616
#include "opencv2/imgcodecs.hpp"
17+
#include "opencv2/core/softfloat.hpp"
1718

1819
#include "opencv2/imgproc/imgproc_c.h"
1920

0 commit comments

Comments
 (0)