Click here to Skip to main content
Licence GPL3
First Posted 14 Nov 2007
Views 72,736
Downloads 4,151
Bookmarked 103 times

Edge Detection in Images with Wavelet Transform

By Chesnokov Yuriy | 14 Nov 2007
This article demonstrates an alternative way for edges extraction compared to conventional image filtering operations with edge detection filters
2 votes, 4.4%
1
1 vote, 2.2%
2
2 votes, 4.4%
3
7 votes, 15.6%
4
33 votes, 73.3%
5
4.77/5 - 45 votes
3 removed
μ 4.60, σa 1.79 [?]
Screenshot - edges.jpg

Introduction

Edge detection is used in computer vision applications for contours extraction of objects. The usual method is to use convolution operation of the image with complex filters like Sobel or Prewitt.

Sobel Filter

Real
1.0  0.0 -1.0
2.0  0.0 -2.0
1.0  0.0 -1.0
Imaginary
1.0  2.0  1.0
0.0  0.0  0.0
-1.0 -2.0 -1.0

Prewitt Filter

Real
0.5  0.0 -0.5
0.5  0.0 -0.5
0.5  0.0 -0.5
Imaginary
0.5  0.5  0.5
0.0  0.0  0.0
-0.5 -0.5 -0.5

You may extract the edges for example with my vec2D wrapper described in my article Vector Class Wrapper SSE Optimized for Math Operations.

However unless integer optimized, floating point operations might take quite a long time. With wavelet transform, you might achieve similar results with a few mathematical operations. For example, Haar transform of the image provides details of that image contained in the high frequency bands very similar in appearance if you used X and Y difference filters on the same image.

X Difference Filter

0.0  0.0  0.0
0.5  0.0 -0.5
0.0  0.0  0.0

Y Difference Filter

0.0  0.5  0.0
0.0  0.0  0.0
0.0 -0.5  0.0

If we keep the details of the image obtained with Haar transform, remove the coarse-grained low frequency component and perform image reconstruction, we obtain the edges of the objects present in the image.

Background

Image processing background for Edge Detection is needed. You might also consult my articles about wavelet analysis of image data: 2D Fast Wavelet Transform Library for Image Processing and Fast Dyadic Image Scaling with Haar Transform.

Using the Code

The code and the demo application are used from my article 2D Fast Wavelet Transform Library for Image Processing where you may find details on how to run the code and use the library. In this project, I added several edge specific operations so you may experiment with different wavelet filters, scales, and denoising thresholds to select the best combination. Below I demonstrate the daub1 filter application, which is the filter used in Haar transform.

Open the image and transform it to 1, 2 or 3 scales. You might add the threshold to remove the noise. Below, the daub1 filter is selected with 1 scale transform without denoising:

1 scale daub1 FWT

You will get this FWT spectrum:

FWT spectrum

Now click Transform->Denoise menu item to remove low frequency component:

Removed low freq component

You might find the corresponding function in the BaseFWT2D class:

void BaseFWT2D::remove_LLband()
{
        if (m_status <= 0)
                return;

        unsigned int width = m_width / 
            (unsigned int)(pow(2.0f, (float)getJ()));
        unsigned int height = m_height / 
            (unsigned int)(pow(2.0f, (float)getJ()));
        
        for (unsigned int y = 0; y < height; y++) 
                for (unsigned int x = 0; x < width; x++)                     
                        spec2d[y][x] = 0;                
}

Now you may reconstruct the image:

In two steps to get edges

It does not seem like the edges yet. You need just subtract 128 from the image and compute the absolute value with Transform->Abs values menu item:

The edges

But the edges are rather vague. First I proceeded with contrast stretching, that is normalizing the image to 0 ... 255 range. But there might be several pixels at the upper limit of the range and it does not really improve the situation. The better choice would be non-linear normalization like logarithmic scale but I just multiply the pixel data by some value and obtain the more prominent edges. For 1 scale transform, the multiplication by 7 works well and does not overflow the 255 limit for the majority of pixels, but for 2 or 3 scales you might diminish the multiplication number.

Now click Transform->Contrast stretch to amplify your edges:

The more prominent edges

You may compare the same picture results I obtained with the Sobel filter. It looks smoother, but then you might proceed to morphological operations like erosion and dilation and get a thin skeleton of the contour so in the end, the results will be very close.

The edges by Sobel filter

I've developed Haar transform MMX optimization and in future, plan to provide an update to the code as EdgeDetector class or something similar and compare the performance.

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)

About the Author

Chesnokov Yuriy

Engineer

Russian Federation Russian Federation

Member
Former Cambridge University postdoc (http://www-ucc-old.ch.cam.ac.uk/research/yc274-research.html), Department of Chemistry, Unilever Centre for Molecular Informatics, where I worked on the problem of complexity analysis of cardiac data.
 
As a subsidiary result we achieved 1st place in the annual PhysioNet/Computers in Cardiology Challenge 2006: QT Interval Measurement (http://physionet.org/challenge/2006/)
 
My research intrests are: digital signal processing in medicine, image and video processing, pattern recognition, AI, computer vision.
 
My recent publications are:
 
Complexity and spectral analysis of the heart rate variability dynamics for distant prediction of paroxysmal atrial fibrillation with artificial intelligence methods. Artificial Intelligence in Medicine. 2008. V43/2. PP. 151-165 (http://dx.doi.org/10.1016/j.artmed.2008.03.009)
 
Face Detection C++ Library with Skin and Motion Analysis. Biometrics AIA 2007 TTS. 22 November 2007, Moscow, Russia. (http://www.dancom.ru/rus/AIA/2007TTS/ProgramAIA2007TTS.html)
 
Screening Patients with Paroxysmal Atrial Fibrillation (PAF) from Non-PAF Heart Rhythm Using HRV Data Analysis. Computers in Cardiology 2007. V. 34. PP. 459–463 (http://www.cinc.org/archives/2007/pdf/0459.pdf)
 
Distant Prediction of Paroxysmal Atrial Fibrillation Using HRV Data Analysis. Computers in Cardiology 2007. V. 34. PP. 455-459 (http://www.cinc.org/archives/2007/pdf/0455.pdf)
 
Individually Adaptable Automatic QT Detector. Computers in Cardiology 2006. V. 33. PP. 337-341 http://www.cinc.org/archives/2006/pdf/0337.pdf)

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
Questionthanks Pinmembertnla0:20 15 Jan '12  
GeneralMy vote of 5 Pinmemberabcdezhao20083:21 17 Nov '11  
GeneralJust comments PinmemberVaclav_Sal12:08 6 Nov '10  
AnswerRe: Just comments PinmemberChesnokov Yuriy9:14 7 Nov '10  
GeneralQuestion Pinmembersergiodd3:46 24 Aug '10  
GeneralRe: Question PinmemberChesnokov Yuriy3:57 24 Aug '10  
GeneralRe: Question [modified] Pinmembersergiodd4:12 24 Aug '10  
GeneralMy vote of 1 PinmemberG.subburaju19:15 21 Dec '09  
GeneralDe-noising PinmemberCPPCoder15:33 16 Apr '08  
Generalneed your help Pinmembergulsaba7:41 31 Mar '08  
Generalcompile problem PinmemberA.DEEPA21:52 21 Mar '08  
AnswerRe: compile problem PinmvpChesnokov Yuriy4:45 25 Mar '08  
GeneralCool Pinmember Dr.Luiji 5:47 19 Dec '07  
Generalserious drawback of this approach Pinmemberhartwin21:49 22 Nov '07  
AnswerRe: serious drawback of this approach - serious drawback with your question :-) PinPopularmemberChesnokov Yuriy23:48 22 Nov '07  
RantRe: serious drawback of this approach PinmemberPythorian21:37 2 Dec '08  
General.jpg image is missing from .zip Pinmemberelwolv3:51 20 Nov '07  
hello
 
.jpg image is missing from .zip
 
elwolv
 
elwolv

GeneralRe: .jpg image is missing from .zip PinmemberChesnokov Yuriy21:05 20 Nov '07  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web02 | 2.5.120210.1 | Last Updated 14 Nov 2007
Article Copyright 2007 by Chesnokov Yuriy
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid