I'm trying to personalise a custom CBIR by adding more features not only based on colour, but based on textures' features.

What I don't know is if I'm approaching this well with Haralick's features.

I'm doing this:

I've used 10 images, 8 for different "textures" and 2 for tests:

enter image description here

All px.jpg are sand images, and all rx.jpg are squares. The test image is squares and test2 image is sand. (NOTE, I don't want to classify, I want a value for each image).

Well, when I query the image test (squares) on the rest of the images (r1, r2, r3, r4, p1, p2, p3, p4) I got the Haralick's features such as Angular 2nd moment, Contrast, Correlation... but I can't find a relationship with the squares, or a not-relationship with sand. I'm making a euclidean distance in this case:

    double features[15]; // I'm introducing other things as well
    Haralick h;

    for (int j = 1; j<=11; j++) {
        float result = sqrt(pow(featurestest[j]-features[j],2));
        if (result > f_max[j]) {
            f_max[j] = result; // to normalize later

        jsonFeatures["F"+to_string(j)] = result;

My question is: am I doing this approach well? if not, how should I do it?

Thank you in advance.

EDIT: If it wasn't clear, I don't want to classify such like I'm doing in the example. I'm using "sand" and "squares" only to make the results more visually when sorting (for example seeing p1 p2 r1 p3 p4 r2 p5 r3 r4 r5 on the final match feature).

  • 1
    $\begingroup$ I would try to use local binary patterns (LBP), that's a really powerful descriptor. Else your approach looks good, except maybe the distance. I am not a specialist on CBIR, but I've read many times that the euclidian distance is not the best for CBIR $\endgroup$
    – FiReTiTi
    Commented Mar 10, 2016 at 19:18

1 Answer 1


Using the Euclidean distance on a feature space will eventually result in a Minimum Distance Classifier which would provide information on the existence or not of a relationship that you seem to be after (for more information please see: http://homepages.inf.ed.ac.uk/rbf/HIPR2/classify.htm).

In your case, if you are using all Haralick features, you are looking at a 13-14 dimensional feature space and a decision boundary that is not a line any more but a plane.

The usual way to do this is to first calculate the "class centroids", that is, the mean values of each feature for each set of sand and checker board images and then, given the features of the test image, calculate its distance from the centroids of each class and select the minimum (i.e. the class centroid that the test-image features are more closely to).

Hope this helps.

  • $\begingroup$ The problem is, in this example I'm having 2 classes, but in the real one I will have only one. That's why I said "I don't want to classify". Imagine I have a set of squares and I want to query one image and see the closest value. How could I afford that?. Thank you for your reply. $\endgroup$ Commented Apr 15, 2015 at 12:55
  • $\begingroup$ You do want to classify :) In that case then, you still want to calculate the centroid of the class and then threshold the distance of test images based on how far away they are from the centroid. This however assumes a spherical point cloud for your features which might not be the case in reality. Can I please ask what your use case is exactly? $\endgroup$
    – A_A
    Commented Apr 15, 2015 at 15:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.