The technique is called halftone. Achieving continuity must be done through subsampling / super-sampling, but the essence of the algorithm goes like this.
Imagine walking across a horizontal line of the image accumulating energy from each input pixel as you go. Once you have accumulated some threshold amount of energy in the accumulator, emit a single pixel, and then reduce the energy stored in the accumulator by a constant amount.
In code, that would be something like:
for (int y = 0; y < height; ++y) {
double accumulator = 0.0;
for (int x = 0; x < width; ++x) {
accumulator += input[x, y];
if (accumulator >= 0.0) {
output[x, y] = 1.0;
accumulator -= K; // try values like 5.0 or more for K.
}
}
}
The larger K
is, the more energy must be accumulated before outputting a pixel, and hence, the more horizontal distance there will be between the lines. If K is 1, that's actually a naïve approach to the dither algorithm.
Supersample to achieve continuity. You can also emit discrete (x,y) points instead of rendering an output pixel directly and then render a new image by rendering a vertical curve passing through the nth point generated of each scanline.
Perform the operation discretely on separate colour channels to get what you described as the "chromatic aberration" effect.
The effect degenerates the more complexity you encounter in the image on a single line. For example, after just two eyes on the same line, the lines are extremely wavy at the right of your example image. Here is the effect exaggerated even more.