* 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 */
| 20 | * repeat - # of times the process is carried out on the previous steps output |
| 21 | */ |
| 22 | array 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 |