Ask Your Question

Texture recognition similar to Cascade Classifier with opencv

asked 2013-04-04 02:34:52 -0500

Immi gravatar image

updated 2013-04-04 03:24:06 -0500

Hello all,

I'm looking for a method to recognize and identify textures. Is there any possibility to create something similar to haarClassifier.xml for textures? I don't want to use template matching.

Thanks in advance!


edit retag flag offensive close merge delete

2 answers

Sort by » oldest newest most voted

answered 2013-09-26 05:53:56 -0500

Immi gravatar image

updated 2013-09-26 05:59:30 -0500

I solved the problem with:

  • calculating the mean color and a compare it with a threshold
  • calculating glcm and compare the glcm with PSNR function (Link to Tutorial)
edit flag offensive delete link more


I am also looking into this area. Are you able to provide some guidance (perhaps share your code with me)? My email is

Thanks a lot!

mrdgw gravatar imagemrdgw ( 2015-10-06 00:31:42 -0500 )edit

answered 2013-04-04 03:59:51 -0500

Basically you could do this very simple.

  • Collect a set of images of what your texture looks like
  • Collect a set of negatives
  • Train a cascade classifier using the train_cascade approach
  • Classify each window as texture or not

However, there must be reasons why people haven't used cascade classifiers for texture recognition. I guess the downside is the amount of time it takes to actually train and create the classifier. Template matching performs more than well enough on textures and a lot of research acknowledges that fact.

edit flag offensive delete link more


Hi Steven,

thank you for your answer. I've tried already Haar-Cascade-Classifier for my problem. It was working quite well(created cascade classifier with about 400 images). I don't want to use template matching on µC later. This is the reason I'm looking for a classifier.

Immi gravatar imageImmi ( 2013-04-04 05:17:42 -0500 )edit

Immi, actually to get a better classification, I am guessing that using about 100 positives would be more than enough, considering you use a large set of negatives. In case of texture, the texture doesn't change that much, but the background does vary alot. You need to model that background variance.

StevenPuttemans gravatar imageStevenPuttemans ( 2013-04-04 06:06:18 -0500 )edit

Hi, I'll try this and reply.

Immi gravatar imageImmi ( 2013-04-04 06:59:18 -0500 )edit

For this task you don't need a cascade classifier, try out the other classifiers (if you are lazy with setting them all up, try WEKA or if you are a python guy ScikitLearn)

Guanta gravatar imageGuanta ( 2013-04-05 08:52:49 -0500 )edit

Doesn't it depend on how hard your texture variates?

StevenPuttemans gravatar imageStevenPuttemans ( 2013-04-05 10:55:51 -0500 )edit

Yeah in some kind you are right, of course you could use a cascade classifier here as well, in principle it is just a variant of AdaBoost which has the ability to reject mismatches very fast, however this may also be a weakness and another classifier, e.g. SVM, Random Forests, etc. may perform better. You should never try only one classifier! Try them all out!

Back to the original question: @Immi It will also depend much on your features you'll use, LBP for example are a popular choice for texture classification, see e.g. , in their paper they also state that they'd make their code publicly available. Good luck

Guanta gravatar imageGuanta ( 2013-04-05 16:45:43 -0500 )edit

Thank you for your help, I' ll try it!

Immi gravatar imageImmi ( 2013-04-08 01:38:19 -0500 )edit

I've solved it with average color and GLCM. Thank you for your hints!

Immi gravatar imageImmi ( 2013-09-24 08:39:14 -0500 )edit

Then post your solution and accept it as the correct one, since it will help others finding solved topics.

StevenPuttemans gravatar imageStevenPuttemans ( 2013-09-24 08:47:52 -0500 )edit

I can't accept my answer at myself. Got to less points.

Immi gravatar imageImmi ( 2013-09-26 05:56:24 -0500 )edit
Login/Signup to Answer

Question Tools


Asked: 2013-04-04 02:34:52 -0500

Seen: 3,729 times

Last updated: Sep 26 '13