Comparing textures with OpenCV and Gabor Filters

computer-vision, image, image-processing, opencv

Solution

Basic approach for encoding texture is to compute a histogram filter responses over the window. You then compare the textures using the histograms. A good way to start is to look at Local Binary Patterns.

Simplified explanation of LBP histogram: every pixel in the input image is described by its 3x3 neighborhood. The neighborhood is converted to index [0,255] by a threshold. The index then identifies the bin in the histogram.

Problem

As part of a project, I'm trying to measure how similar are 2 textures sampled from an image. (I take 2 squared samples of about 40 x 40 px). After I take the samples, I pass them to a bank of Gabor filters (with 2 filter sizes and 6 orientations) so now I have 12 filter outputs for each sample. The objective is to compute a metric that tells us how similar 2 textures are, in such a way that if the 2 samples are wood or brick, the metric score is low (the difference is small) but if 1 sample is rock and other is fabric then the metric should be high (the textures are very different). The question is: How could I measure the texture difference using this outputs? I was suggested to create a distribution of the outputs for each sample and then measure the distance between the 2 distributions, but I just have no idea of how to do that. The filters look something like (tough not exactly): The output looks something like this (I borrowed this image just as an example)

Original source