1
$\begingroup$

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?

enter image description here

$\endgroup$
1
$\begingroup$

These are the two approaches I have taken


Mathematica graphics

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], 
        {"LargestCoefficients", 50}]] // ImageAdjust

Mathematica graphics


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

Mathematica graphics

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 *)
flags = Thread[Map[MemberQ[mask, #1] &, First /@ lwdcoeffs]];

(* 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,
        BiorthogonalSplineWavelet[3, 1], LiftingWaveletTransform]] // ImageAdjust

Mathematica graphics

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

Mathematica graphics

$\endgroup$
  • $\begingroup$ @Mike Hope this sheds some light $\endgroup$ – Sektor Feb 9 '15 at 18:18
  • $\begingroup$ Many thanks, Sektor. Excellent work! It certainly shows that this sort of approach may be successful - at least to an extent anyway. :) $\endgroup$ – Mike Miller Feb 9 '15 at 19:48
  • 1
    $\begingroup$ The pleasure is all mine ! If I can further assist you - do contact me. $\endgroup$ – Sektor Feb 9 '15 at 19:53
  • $\begingroup$ 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. $\endgroup$ – Mike Miller Feb 18 '15 at 14:11
  • 1
    $\begingroup$ Thanks once again :) I was actually reading his papers from Bell Labs, so on the right track I hope! $\endgroup$ – Mike Miller Feb 19 '15 at 22:59
1
$\begingroup$

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:

Mathematica graphics

(* img *)

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

Here's how the decomposition tree looks like

Mathematica graphics

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}.

Mathematica graphics

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

Mathematica graphics

$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – Mike Miller Feb 3 '15 at 10:24
  • $\begingroup$ 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. $\endgroup$ – Sektor Feb 3 '15 at 14:16
  • $\begingroup$ 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. $\endgroup$ – Mike Miller Feb 3 '15 at 14:27
  • $\begingroup$ 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. $\endgroup$ – Sektor Feb 3 '15 at 14:34
  • 1
    $\begingroup$ Good luck for the exam! :) $\endgroup$ – Mike Miller Feb 3 '15 at 14:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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