MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / TEST

Function TEST

test/gray_rgb.cpp:104–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

102}
103
104TEST(rgb_gray, MaxDim) {
105 size_t largeDim = 65535 * 32 + 1;
106 array rgb = randu(1, largeDim, 3, u8);
107 array gray = rgb2gray(rgb);
108
109 vector<uchar> h_rgb(rgb.elements());
110 vector<float> h_gray(gray.elements());
111
112 rgb.host(&h_rgb[0]);
113 gray.host(&h_gray[0]);
114
115 int num = gray.elements();
116 int roff = 0;
117 int goff = num;
118 int boff = 2 * num;
119
120 const float rPercent = 0.2126f;
121 const float gPercent = 0.7152f;
122 const float bPercent = 0.0722f;
123
124 for (int i = 0; i < num; i++) {
125 float res = rPercent * h_rgb[i + roff] + gPercent * h_rgb[i + goff] +
126 bPercent * h_rgb[i + boff];
127
128 ASSERT_FLOAT_EQ(res, h_gray[i]);
129 }
130}

Callers 1

gray_rgb.cppFile · 0.70

Calls 4

randuFunction · 0.85
hostMethod · 0.80
rgb2grayFunction · 0.50
elementsMethod · 0.45

Tested by

no test coverage detected