Discrete Wavelets with Applications

064b - Haar Edge Detection

Helmut  Knaust - Department of Mathematical Sciences, University of Texas at El Paso, hknaust@utep.edu
04/02/09. Last edit: 03/20/2025.

"Naive" Method Using the Haar Wavelet Transform

SetDirectory[NotebookDirectory[]];<<DW.wl
SetDirectory["Images2"];

pic=Import["Skyline.jpg","Data"];
pic=NTSC[pic];
ImagePlot[pic]

We are applying the Haar transform once :

p1=HaarWLT[pic,1];
ImagePlot[p1,Scaled->True]

The blur portion is set to 0 :

{r,c}=Dimensions[p1];
p1[[1;;r/2,1;;c/2]]=Table[0,{i,1,r/2},{j,1,c/2}];
ImagePlot[p1,Scaled->True]

Now we are applying the inverse Haar wavelet transform :

p1=Transpose[Haar[r]].p1.Haar[c];
ImagePlot[p1,Scaled->True]

Below are pictures of the absolute value of the resulting matrix and of its negative.

ImagePlot[Abs[p1],Scaled->True]
ImagePlot[255-Abs[p1],Scaled->True]

Using the Gonzalez and Woods Thresholding Algorithm

?HaarThreshold

p2=HaarThreshold[pic,1];
ImagePlot[Abs[p2],Scaled->True]
ImagePlot[255-Abs[p2],Scaled->True]