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

Function pick

examples/image_processing/filters.cpp:73–88  ·  view source on GitHub ↗

* randomization - controls % of total number of pixels in the image * that will be effected by random noise * repeat - # of times the process is carried out on the previous steps output */

Source from the content-addressed store, hash-verified

71 * repeat - # of times the process is carried out on the previous steps output
72 */
73array pick(const array &in, int randomization, int repeat) {
74 int w = in.dims(0);
75 int h = in.dims(1);
76 float f = randomization / 100.0f;
77 int dim = (int)(f * w * h);
78 array ret_val = in.copy();
79 for (int i = 0; i < repeat; ++i) {
80 array idxs = (w * h) * randu(dim);
81 array rnd = getRandomNeighbor(ret_val, 1, 1);
82 array temp_src = moddims(rnd, w * h, 3);
83 array temp_dst = moddims(ret_val, w * h, 3);
84 temp_dst(idxs, span) = temp_src(idxs, span);
85 ret_val = moddims(temp_dst, in.dims());
86 }
87 return ret_val;
88}
89
90void prewitt(array &mag, array &dir, const array &in) {
91 static float h1[] = {1, 1, 1};

Callers 1

mainFunction · 0.85

Calls 5

randuFunction · 0.85
getRandomNeighborFunction · 0.85
moddimsFunction · 0.85
dimsMethod · 0.45
copyMethod · 0.45

Tested by

no test coverage detected