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

Function channel_split

src/api/c/imageio_helper.h:80–104  ·  view source on GitHub ↗

Split a MxNx3 image into 3 separate channel matrices. Produce 3 channels if needed

Source from the content-addressed store, hash-verified

78// Split a MxNx3 image into 3 separate channel matrices.
79// Produce 3 channels if needed
80static af_err channel_split(const af_array rgb, const af::dim4 &dims,
81 af_array *outr, af_array *outg, af_array *outb,
82 af_array *outa) {
83 try {
84 af_seq idx[4][3] = {{af_span, af_span, {0, 0, 1}},
85 {af_span, af_span, {1, 1, 1}},
86 {af_span, af_span, {2, 2, 1}},
87 {af_span, af_span, {3, 3, 1}}};
88
89 if (dims[2] == 4) {
90 AF_CHECK(af_index(outr, rgb, dims.ndims(), idx[0]));
91 AF_CHECK(af_index(outg, rgb, dims.ndims(), idx[1]));
92 AF_CHECK(af_index(outb, rgb, dims.ndims(), idx[2]));
93 AF_CHECK(af_index(outa, rgb, dims.ndims(), idx[3]));
94 } else if (dims[2] == 3) {
95 AF_CHECK(af_index(outr, rgb, dims.ndims(), idx[0]));
96 AF_CHECK(af_index(outg, rgb, dims.ndims(), idx[1]));
97 AF_CHECK(af_index(outb, rgb, dims.ndims(), idx[2]));
98 } else {
99 AF_CHECK(af_index(outr, rgb, dims.ndims(), idx[0]));
100 }
101 }
102 CATCHALL;
103 return AF_SUCCESS;
104}
105
106#endif
107}

Callers 3

af_save_imageFunction · 0.70
af_save_image_memoryFunction · 0.70
save_tFunction · 0.70

Calls 2

af_indexFunction · 0.70
ndimsMethod · 0.45

Tested by

no test coverage detected