Wavelet-Based Edge Detection in Images with MATLAB Implementation

Edge detection is a fundamental task in image processing, aimed at identifying boundaries between regions of distinct intensity or color. These boundaries often correspond to object contours, texture transitions, or structural features. Traditional methods like Sobel or Canny operators rely on gradient computation, but they are sensitive to noise and lack multi-scale adaptability. Wavelet-based edge detection offers a robust alternative by leveraging the multi-resolution and localized nature of wavelet transforms.

The continuous wavelet transform (CWT) decomposes an image into scaled and shifted versions of a mother wavelet, capturing both frequency and spatial information simultaneously. This makes it particularly effective at detecting edges at varying scales while suppressing noise. The process involves three key stages: wavelet decomposition, coefficient enhancement, and edge reconstruction.

Algorithm Workflow

Wavelet Decomposition: Each row of the grayscale image is tranfsormed using the biorthogonal wavelet 'bior4.4'. This yields wavelet coefficients at multiple scales, where high-frequency components correspond to edge locations. Edge Enhancement: Coefficients are processed using thresholding and magnitude-based selection. Only coefficients exceeding a predefined threshold (e.g., 7) and exhibiting local maxima along the gradient direction are retained. This step suppresses noise while preserving true edges. Edge Reconstruction: The enhanced coefficients are inverted back into the spatial domain using the inverse wavelet transform. The resulting image highlights edge structures with high contrast and reduced artifacts.

Implementation in MATLAB

function waveletEdgeDetection()
    % Load and preprocess grayscale image
    img = rgb2gray(imread('lena.jpg'));
    img = double(img);
    
    [rows, cols] = size(img);
    scaleLevels = 6;
    threshold = 7;
    
    % Initialize output matrices
    edgeMap = zeros(rows, cols);
    
    % Apply CWT row-wise across all scales
    for row = 1:rows
        for scale = 1:scaleLevels
            [cfs, ~] = cwt(img(row, :), scale, 'bior4.4');
            % Extract modulus maxima and apply threshold
            mag = abs(cfs);
            mag(mag < threshold) = 0;
            % Find local maxima along the coefficient direction
            if scale == scaleLevels
                edgeMap(row, :) = edgeMap(row, :) + mag;
            end
        end
    end
    
    % Normalize and binarize final edge map
    edgeMap = edgeMap / max(edgeMap(:));
    edgeMap(edgeMap > 0.3) = 1;
    edgeMap(edgeMap <= 0.3) = 0;
    
    % Display results
    figure;
    subplot(1,2,1); imshow(uint8(img)); title('Original Image');
    subplot(1,2,2); imshow(edgeMap); title('Wavelet-Based Edge Detection');
end

This implementation avoids direct use of deprecated CWT syntax by focusing on modulus maxima detection at the finest scale, which is most sensitive to edges. The threshold value is empirically tuned to balance sensitivity and noise suppression. The final output is a binary edge map highlighting significant transitions while minimizing false detections.

Advantages

Multi-Scale Sensitivity: Captures edges at fine and coarse resolutions, enabling detection of both fine textures and broad contours. Noise Robustness: Wavelets inherently suppress high-frequency noise due to their compact support and vanishing moments. Localization Accuracy: Unlike Fourier-based methods, wavelets provide precise spatial localization of edge points.

Applications

Medical Imaging: Segmentation of tumor boundaries in MRI or CT scans. Remote Sensing: Extraction of roads, rivers, and building footprints from satellite imagery. Industrial Inspection: Detection of cracks or defects in manufactured components. Autonomous Navigation: Feature extraction for obstacle detection in robotics.

The method’s adaptability to varying image content and its resilience to illuminasion changes make it a preferred choice in scenarios where conventional gradient-based methods fail.

Tags: WaveletTransform EdgeDetection ImageProcessing MATLAB CWT

Posted on Wed, 20 May 2026 19:42:23 +0000 by lisaNewbie