To be able to compare to images by their texure, they must be quantified in a way other than just plotting the pixels in RGB space.

A useful method for this purpose seems the Fourier Analysis. I knew about this mainly from the domain of music, where a sound wave (a one dimensional matrix) is split up in its parts – pure sinusoidal waves of different frequencies and different magnitudes. This analysis (FFT – Fast Fourier Transformaion) is also widely used in image processing, where its two dimensional version is applied to the image’s matrix of brightness (or better luminance) values.

Some first experiments were made with rebuilding a sample image by overlaying an increasing range of the frequency spectrum, defined by the radius of the dot in the frequency filter mask.

original source code taken from here