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

Function morph

src/backend/cpu/morph.cpp:24–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

22namespace cpu {
23template<typename T>
24Array<T> morph(const Array<T> &in, const Array<T> &mask, bool isDilation) {
25 af::borderType padType = isDilation ? AF_PAD_ZERO : AF_PAD_CLAMP_TO_EDGE;
26 const af::dim4 &idims = in.dims();
27 const af::dim4 &mdims = mask.dims();
28
29 const af::dim4 lpad(mdims[0] / 2, mdims[1] / 2, 0, 0);
30 const af::dim4 &upad(lpad);
31 const af::dim4 odims(lpad[0] + idims[0] + upad[0],
32 lpad[1] + idims[1] + upad[1], idims[2], idims[3]);
33
34 auto out = createEmptyArray<T>(odims);
35 auto inp = padArrayBorders(in, lpad, upad, padType);
36
37 if (isDilation) {
38 getQueue().enqueue(kernel::morph<T, true>, out, inp, mask);
39 } else {
40 getQueue().enqueue(kernel::morph<T, false>, out, inp, mask);
41 }
42
43 std::vector<af_seq> idxs(4, af_span);
44 idxs[0] = af_seq{double(lpad[0]), double(lpad[0] + idims[0] - 1), 1.0};
45 idxs[1] = af_seq{double(lpad[1]), double(lpad[1] + idims[1] - 1), 1.0};
46
47 return createSubArray(out, idxs);
48}
49
50template<typename T>
51Array<T> morph3d(const Array<T> &in, const Array<T> &mask, bool isDilation) {

Callers

nothing calls this directly

Calls 5

padArrayBordersFunction · 0.70
createSubArrayFunction · 0.70
getQueueFunction · 0.50
dimsMethod · 0.45
enqueueMethod · 0.45

Tested by

no test coverage detected