# Can wavelets be used for complex texture discrimination?

I've recently been studying wavelet analysis with a view to differentiating certain areas of texture images where the texture differs from the background pattern (which is quite random); for example a small ink smudge on a photo of sand or similar.

I've seen a lot of applications of Gabor wavelets used to pick out textural differences in things like fabrics, and other regular type patterns but I've not been able to find any applications of things like Daubechie/Harr wavelets for anything other than image compression.

Can different wavelet families be used to pick out textural differences such as my example or am I wasting my time?

These are the two approaches I have taken

img (* sample image *)

f[arg_Image] := Log[1 + #^2] & /@ ImageData[arg]

lwd = LiftingWaveletTransform[img, BiorthogonalSplineWavelet[1, 3], 3, Padding -> 0,
Method -> "IntegerLifting"]

lwdcoeffs = lwd[All, {"Image", "ImageFunction" -> ImageAdjust, ImageSize -> 120}];

(* We scale the coefficients; Log[1 + coefficient^2] *)
lwdlogcoeffs = First@# -> Image@f[Last@#] & /@ lwdcoeffs;

(* And now invert the transform but with a higher order wavelet *)
(* While retaining the 50 largest coefficients                  *)
InverseWaveletTransform[WaveletThreshold[DiscreteWaveletData[lwdlogcoeffs,
BiorthogonalSplineWavelet[2, 2], LiftingWaveletTransform],


transformedlwdcoeffs = MapThread[#1[[1]] -> Binarize[GaussianFilter[DistanceTransform[#1[[2]]], 1,
{2, 2}]] &, {lwdcoeffs}]


Eh, not too shabby - we will use this as a mask

(* Extract the coefficients we are interested in *)
mask = First /@ lwd[{___, 0}]

(* True if it is a coefficient we are going to use; False - otherwise *)

(* Multiply the mask and the original coefficients while using flags as an indicator *)
lwdobject = MapThread[If[#1[[1]] == #2[[1]] && #3,
#1[[1]] -> ImageMultiply[#1[[2]], #2[[2]]],
#1[[1]] -> #1[[2]]] &, {lwdcoeffs, transformedlwdcoeffs, flags}];

(* Now invert the transform *)

InverseWaveletTransform[DiscreteWaveletData[lwdobject,


It's far from perfect, but I think it is a proof of concept.

You can also filter based on the histograms of the image and the LiftingWaveletTransform coefficients

• @Mike Hope this sheds some light Feb 9 '15 at 18:18
• Many thanks, Sektor. Excellent work! It certainly shows that this sort of approach may be successful - at least to an extent anyway. :) Feb 9 '15 at 19:48
• The pleasure is all mine ! If I can further assist you - do contact me. Feb 9 '15 at 19:53
• Hi Sektor, where did you learn how to use the lifting scheme? I'm going to have a try a few things myself over the next few days with Matlab, maybe construct some wavelets myself if I can. Feb 18 '15 at 14:11
• Thanks once again :) I was actually reading his papers from Bell Labs, so on the right track I hope! Feb 19 '15 at 22:59

I think you should just dig deeper and get your hands dirty. I have used Mathematica as it is the fastest way I can model something like this

As an example:

(* img *)

dwd = DiscreteWaveletTransform[img, BiorthogonalSplineWavelet[1, 3], 4]


Here's how the decomposition tree looks like

You can then extract every coefficient

coeffs = dwd[{___, 0 | 1 | 2 | 3}, {"Image", "ImageFunction" -> Identity, ImageSize -> 120}]


From left to right {0}, {1}, {2} and {3}.

And you can compare those to the coefficients after applying the 1 + Log[coeff^2] function to them

• Thanks for the answer. I've tried a few things like this on simple examples such as yours. I'm having more trouble with subtle discolourations, when the colour intensity values do not change by a huge amount, but you can still spot it quite easily with the eye. I'm wondering whether it would be feasible to design a wavelet family suited to the feature you're trying to pick out. Feb 3 '15 at 10:24
• Do you have such sample images I can work on ? Hmm, if you have to define a new wavelet family for every new feature you are trying to extract is not feasible, time wise, but of course if done correctly will work much better. Feb 3 '15 at 14:16
• I've edited the OP with an example type of texture. This is the general sort of thing I'm looking to do; pick out the highlighted area from background textures. I appreciate the help, but please don't go to too much trouble! I'm more looking to know whether this sort of thing is feasible in case I'm wasting my time. I was thinking I could identify general types of features and use specific wavelet families based on what I'm looking for. Feb 3 '15 at 14:27
• Don't worry - it is not wasted time for me :) Sadly, I will be able to play around after tomorrow - I have a final in the morning. Feb 3 '15 at 14:34
• Good luck for the exam! :) Feb 3 '15 at 14:49