Ask Your Question

Algorithm recommendation for texture analysis/segmentation

asked 2018-03-20 23:35:38 -0500

eudoxos gravatar image

updated 2018-03-21 06:44:50 -0500

I need to find areas with bulk of spherical objects (for further analysis) when the image contains also areas which are not interesting. A typical image looks like this:

image description

I tried texture analysis using Gabor filter, rotating them around, and checking where they match multiple directions (threshold and blur the result, add all of them together, dilate the result to get contiguous area), indicating there are edges in all directions (which will be the case for spheres but not for flat areas, like that one on the right) - this is in one particular direction:

image description

and this is the final result:

image description

It could be made better by tuning various params, but before I go there: I'd like to have suggestions for a better-suited algorithm for this task -- I've been browsing the internet for texture analysis strategies, such as Haralick features, SURF and others, but having no experience with any of those, it is hard to decide which path to pursue. I hope someone might point me to the right direction. The implementation will be in c++/OpenCV. Thanks!

EDIT: The approach must also work on b/w images, not supposing any particular colors, purely by analyzing texture.

edit retag flag offensive close merge delete


The world is moving towards Deep Neural Networks! Why not try those? 12

Balaji R gravatar imageBalaji R ( 2018-03-20 23:56:28 -0500 )edit

Deep learning is not the solution for all. At least you will need thousand and much more images for learning which is not always available.

VxW gravatar imageVxW ( 2018-03-21 03:20:04 -0500 )edit

@VxW actually that is incorrect. Due to the uprising trend of transfer learning and pretrained weight files on large datasets like pascal VOC, training a classification system for these problems can easily be done with only a hundred samples per class, possibly even lower (we have a multi class system running with 15 samples per class as training data only)...

StevenPuttemans gravatar imageStevenPuttemans ( 2018-03-21 05:40:32 -0500 )edit

3 answers

Sort by » oldest newest most voted

answered 2018-03-21 12:21:41 -0500

kbarni gravatar image

I think this is a classical texture classification problem, so a classical method should work. These are fast and robust methods. I think you were on the right track with the Gabor filters, only the size of the filters wasn't well chosen.

Another good and fast texture descriptor are the Haralick features. It isn't part of OpenCV, but implementing it is very easy.

If your texture has a typical color, you can also use the mean H,S,V values as features.

For the classification, I prefer to use the SVM for this kind of problem.

So the algorithm again: Take a sliding window; compute the Haralick features on the window. Or run Gabor filters on the image. Use the Haralick features or the results of the Gabor filter for the current pixel as input vector for an SVM, it will give you the texture class for the current pixel.

Use images of pure texture to train the SVM.

edit flag offensive delete link more


Thanks. Will this work also if I have only 1 class of texture, and want to find it against anything else? I will just throw any random images without that texture into the training set as "other" or something like that?

eudoxos gravatar imageeudoxos ( 2018-03-24 08:30:18 -0500 )edit

I don't really know, I never did one-class texture recognition. The method you describe will probably work.

kbarni gravatar imagekbarni ( 2018-03-25 13:55:51 -0500 )edit

@kbarni, I used HSV values with robots in real-time, it was very good but when illumination changes happens it is bad. I wonder if image texture will fix this problem. Please your opinion?

redhwan gravatar imageredhwan ( 2020-03-29 20:47:01 -0500 )edit

Yes, most of the texture attributes are robust to illumination changes (in fact that's one of the main reasons to use texture analysis).

Just take care to correctly train your SVM. If you use images taken with different illuminations, the parameters will be adjusted accordingly, giving less weight to luminosity-related indices (like energy from the Haralick features).

kbarni gravatar imagekbarni ( 2020-03-30 04:16:43 -0500 )edit

Thanks a lot for your reply, @kbarni, I used Gabor filter first, Do I need to use SVM as classifier. here full my code.

Please help me.

redhwan gravatar imageredhwan ( 2020-03-30 09:14:09 -0500 )edit

answered 2018-03-21 07:54:12 -0500

updated 2018-03-21 07:55:24 -0500

So what I suggest is an approach on the Darknet19 CNN classifier. If time is not an issue, than go for the DenseNet201 architecture, because it is simply so powerful!

  • Use transfer learning to train a new model using the original architecture
  • Use OpenCV DNN interface to read in the model and process your images

I am pretty sure collecting 50 sample patches will already get you pretty far!

edit flag offensive delete link more

answered 2018-03-21 03:34:45 -0500

VxW gravatar image


if you only need the area of the spherical objects I would first apply a median filter:

image description

Afterwards you can use a KMeans Color Quantization see docu

image description

based on this mask you can do now your further analysis


edit flag offensive delete link more



I'm sorry your answer is based on Color based segmentation! But the OP question was about Texture based segmentation! e.g If the Input Image is Gray scale Image, it should work without any problem!

Balaji R gravatar imageBalaji R ( 2018-03-21 05:15:47 -0500 )edit

Your approach is only working if you have any clue on how many classes will be in the image. IF in the next setup, you have 4 different textures, than that will never work. OR as @Balaji R said, if two similar colored different textured classes occur, they will get classified as the same class here.

StevenPuttemans gravatar imageStevenPuttemans ( 2018-03-21 05:42:31 -0500 )edit

Color-based segmentation is indeed ruled out. I added a note to the question.

eudoxos gravatar imageeudoxos ( 2018-03-21 06:45:28 -0500 )edit

Question Tools

1 follower


Asked: 2018-03-20 23:35:38 -0500

Seen: 10,559 times

Last updated: Mar 21 '18