PostGIS  2.3.7dev-r@@SVN_REVISION@@
static void test_rgb_to_hsv ( )
static

Definition at line 27 of file raster/test/cunit/cu_misc.c.

References rt_util_rgb_to_hsv().

Referenced by misc_suite_setup().

27  {
28  double rgb[3] = {0, 0, 0};
29  double hsv[3] = {0, 0, 0};
30 
31  rt_util_rgb_to_hsv(rgb, hsv);
32  CU_ASSERT_DOUBLE_EQUAL(hsv[0], 0, DBL_EPSILON);
33  CU_ASSERT_DOUBLE_EQUAL(hsv[1], 0, DBL_EPSILON);
34  CU_ASSERT_DOUBLE_EQUAL(hsv[2], 0, DBL_EPSILON);
35 
36  rgb[0] = 0;
37  rgb[1] = 0;
38  rgb[2] = 1;
39  rt_util_rgb_to_hsv(rgb, hsv);
40  CU_ASSERT_DOUBLE_EQUAL(hsv[0], 2/3., DBL_EPSILON);
41  CU_ASSERT_DOUBLE_EQUAL(hsv[1], 1, DBL_EPSILON);
42  CU_ASSERT_DOUBLE_EQUAL(hsv[2], 1, DBL_EPSILON);
43 
44  rgb[0] = 0;
45  rgb[1] = 0.25;
46  rgb[2] = 0.5;
47  rt_util_rgb_to_hsv(rgb, hsv);
48  CU_ASSERT_DOUBLE_EQUAL(hsv[0], 7/12., DBL_EPSILON);
49  CU_ASSERT_DOUBLE_EQUAL(hsv[1], 1, DBL_EPSILON);
50  CU_ASSERT_DOUBLE_EQUAL(hsv[2], 0.5, DBL_EPSILON);
51 
52  rgb[0] = 0.5;
53  rgb[1] = 1;
54  rgb[2] = 0.5;
55  rt_util_rgb_to_hsv(rgb, hsv);
56  CU_ASSERT_DOUBLE_EQUAL(hsv[0], 1/3., DBL_EPSILON);
57  CU_ASSERT_DOUBLE_EQUAL(hsv[1], 0.5, DBL_EPSILON);
58  CU_ASSERT_DOUBLE_EQUAL(hsv[2], 1, DBL_EPSILON);
59 
60  rgb[0] = 0.2;
61  rgb[1] = 0.4;
62  rgb[2] = 0.4;
63  rt_util_rgb_to_hsv(rgb, hsv);
64  CU_ASSERT_DOUBLE_EQUAL(hsv[0], 0.5, DBL_EPSILON);
65  CU_ASSERT_DOUBLE_EQUAL(hsv[1], 0.5, DBL_EPSILON);
66  CU_ASSERT_DOUBLE_EQUAL(hsv[2], 0.4, DBL_EPSILON);
67 }
rt_errorstate rt_util_rgb_to_hsv(double rgb[3], double hsv[3])
Definition: rt_util.c:503

Here is the call graph for this function:

Here is the caller graph for this function: