Original photo of a tree by Crusier, copyright 2011. Derivative by Kragen Javier Sitaker, copyright 2012. Both licensed under cc-by-sa.
Two of the images on this page depict women with bare breasts. If that bothers you, you should probably close this web page before scrolling down.
I wrote an algorithm to produce black-and-white, somewhat abstract versions of photographs, by median-thresholding a high-pass-filtered version of the image. This super-simplistic approach works okay at producing engraving-like or Xerox-like images. In fact, it works far better than it has any right to.
In somewhat more detail, the input image is converted to grayscale; a blurred version is generated; a difference of the blurred version and the original is computed, thus high-pass filtering the image; and a weighted sum of 95% high-pass-filtered and 5% original grayscale image is computed. Then this weighted sum is discretized and thresholded at its median to produce black and white pixels.
Or, as follows, with PIL and Python Numeric:
gray = image.convert("L") # Convert image to grayscale. blurred = gray.filter(ImageFilter.BLUR) differences = autostretch(image2array(gray) - 0.95 * image2array(blurred) + 0.5) output = threshold(differences, median(differences))
Full source code downloadable and posted to kragen-hacks.
In a sense, you can think of this algorithm as making the tradeoff between spatial resolution and color depth dynamically, according to the texture of each area. Heavily textured areas are simple line drawings, while smoother areas are more dithered.
Original photo of a tree by Crusier, copyright 2011. Derivative by Kragen Javier Sitaker, copyright 2012. Both licensed under cc-by-sa.
Original photo of Jere in concert by Luis Hernandez. Derivative by Kragen Javier Sitaker. Both copyright 2012, licensed under cc-by.
Original photo of Leia hanging from a tree by David Levine, copyright 2009. Derivative by Kragen Javier Sitaker, copyright 2012. Both licensed under cc-by.
Original photo of a dimly illuminated woman by Ralf Roletschek. Derivative by Kragen Javier Sitaker. Both copyright 2012, licensed under the Free Art License 1.3.
Pitfalls: Too much noise in the photo makes it come out looking too normal. Too much texture in an area tends to reduce its color to mid-gray. Smooth areas look a lot better if you render them to bitmaps at much higher than screen resolution and then scale them down. JPEG artifacts can be spectacular. No attempt is made to shade smooth surfaces using lines rather than scattered points.