The iconic artist Chuck Close creates realistic images that are painstakingly built up from tiny tiles. This function provides a quick fix for those who want to emulate Close's style but without putting in all that pesky hard work.
The function accepts three arguments: an image that you want to manipulate (either a matrix or a file name), and parameters that control the number of rows and columns of tiles in the final image. Each tile is constructed by drawing a randomly chosen number of successively smaller (rounded) rectangles. The elements of each tile are colored randomly, subject to the constraint that the mean R,G,B values of each of the tile's elements must equal the mean R,G,B values of the pixels at the corresponding locations in the original image. The user may also pass in an optional fourth argument which specifies the filename in which to save the result as a vectorized PDF.
This submission is intended to be entertaining and possibly interesting. However, it should not be used as a substitute for viewing Chuck Close's actual art, which is much prettier than anything this computer program will produce.
fixed tile color bug, made tile elements more interesting and varied.