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

Function hurl

examples/image_processing/filters.cpp:22–40  ·  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

20 * repeat - # of times the process is carried out on the previous steps output
21 */
22array hurl(const array &in, int randomization, int repeat) {
23 int w = in.dims(0);
24 int h = in.dims(1);
25 float f = randomization / 100.0f;
26 int dim = (int)(f * w * h);
27 array ret_val = in.copy();
28 array temp = moddims(ret_val, w * h, 3);
29 for (int i = 0; i < repeat; ++i) {
30 array idxs = (w * h) * randu(dim);
31 array rndR = 255.0f * randu(dim);
32 array rndG = 255.0f * randu(dim);
33 array rndB = 255.0f * randu(dim);
34 temp(idxs, 0) = rndR;
35 temp(idxs, 1) = rndG;
36 temp(idxs, 2) = rndB;
37 }
38 ret_val = moddims(temp, in.dims());
39 return ret_val;
40}
41
42/**
43 * Retrieve a new image of same dimensions of the original image

Callers 1

mainFunction · 0.85

Calls 4

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

Tested by

no test coverage detected