Comparing textures with OpenCV and Gabor Filters

10,570

Solution 1

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.

Solution 2

I know this is an old thread now, but this page might help future visitors: https://scikit-image.org/docs/dev/auto_examples/features_detection/plot_gabor.html

It is an example in Python that uses the mean and the variance of the filtered image as discriminative features (refer to function 'compute_feats'). The metric for comparison is simply the least squared error (refer to function 'match').

Share:
10,570
ButterDog
Author by

ButterDog

Updated on June 05, 2022

Comments

  • ButterDog
    ButterDog almost 2 years

    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):

    Filter bank

    The output looks something like this (I borrowed this image just as an example)

    enter image description here