
464 A Computational Introduction to Digital Image Processing, Second Edition
MATLAB/Octave
>> x=1:12;
>> x+mod(x,4)
ans
=
2 4 6 4 6 8 10 8 10 12 14 12
or
Python
In : x = np.array(range(1,13))
In : print np.vstack((x,x+x%4))
[[ 1 2 3 4 5 6 7 8 9 10 11 12]
[ 2 4 6 4 6 8 10 8 10 12 14 12]]
Notice that although the values increase from left to right, they do in small runs, which
seem to overlap. On an image, the appearance will be of a ripple across the image. We
shall experiment first using Cartesian coordinates:
MATLAB/Octave
>> [y,x] = meshgrid(1:cols,1:rows);
>> y2 = y+mod(y,32);
>> y2 = clip(y2,1,cols);
Here we have just added moduli across the columns, then