| 73 | |
| 74 | template<typename T, typename cType> |
| 75 | static af_array gray2rgb(const af_array& in, const float r, const float g, |
| 76 | const float b) { |
| 77 | if (r == 1.0 && g == 1.0 && b == 1.0) { |
| 78 | dim4 tileDims(1, 1, 3, 1); |
| 79 | return getHandle(arrayfire::common::tile(getArray<T>(in), tileDims)); |
| 80 | } |
| 81 | |
| 82 | af_array mod_input = 0; |
| 83 | dim4 inputDims = getInfo(in).dims(); |
| 84 | |
| 85 | dim4 matDims(inputDims[0], inputDims[1], 1, inputDims[2] * inputDims[3]); |
| 86 | |
| 87 | AF_CHECK(af_moddims(&mod_input, in, matDims.ndims(), matDims.get())); |
| 88 | Array<cType> mod_in = cast<cType>(getArray<cType>(mod_input)); |
| 89 | |
| 90 | Array<cType> rCnst = createValueArray<cType>(matDims, scalar<cType>(r)); |
| 91 | Array<cType> gCnst = createValueArray<cType>(matDims, scalar<cType>(g)); |
| 92 | Array<cType> bCnst = createValueArray<cType>(matDims, scalar<cType>(b)); |
| 93 | |
| 94 | Array<cType> expr1 = arithOp<cType, af_mul_t>(mod_in, rCnst, matDims); |
| 95 | Array<cType> expr2 = arithOp<cType, af_mul_t>(mod_in, gCnst, matDims); |
| 96 | Array<cType> expr3 = arithOp<cType, af_mul_t>(mod_in, bCnst, matDims); |
| 97 | |
| 98 | AF_CHECK(af_release_array(mod_input)); |
| 99 | |
| 100 | // join channels |
| 101 | dim4 odims(expr1.dims()[0], expr1.dims()[1], 3); |
| 102 | Array<cType> out = createEmptyArray<cType>(odims); |
| 103 | join<cType>(out, 2, {expr3, expr1, expr2}); |
| 104 | return getHandle(out); |
| 105 | } |
| 106 | |
| 107 | template<typename T, typename cType, bool isRGB2GRAY> |
| 108 | static af_array convert(const af_array& in, const float r, const float g, |
no test coverage detected