* 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 */
| 71 | * repeat - # of times the process is carried out on the previous steps output |
| 72 | */ |
| 73 | array 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 | |
| 90 | void prewitt(array &mag, array &dir, const array &in) { |
| 91 | static float h1[] = {1, 1, 1}; |