Binary Crack Fracture Splicing Algorithm Based on Geometric Constraints

Preprocessing Stage

Image Denoising

% Load binary crack image<br>binary_img = imread('crack_binary.png');<br><br>% Apply adaptive median filtering to remove isolated noise points<br>filtered_img = medfilt2(binary_img, [3 3], 'symmetric');<br><br>% Use morphological closing operation to connect fractured cracks<br>structuring_element = strel('disk', 2);<br>closed_img = imclose(filtered_img, structuring_element);<br>

Crack Region Enhancement

% Calculate gradient directions of the crack<br>[grad_x, grad_y] = imgradientxy(closed_img);<br>angle_map = atan2d(grad_y, grad_x);<br><br>% Apply directional consistency filtering to suppress noise in non-crack directions<br>threshold_angle = 15; % Allowed angular deviation threshold<br>direction_mask = abs(angle_map - mean(angle_map(:))) < threshold_angle;<br>enhanced_img = imadjust(multiply(closed_img, double(direction_mask)));<br>

Crack Feature Extraction

Contour Detection and Endpoint Positioning

% Extract connected components<br>connected_components = bwconncomp(enhanced_img);<br>region_stats = regionprops(connected_components, 'Centroid', 'BoundingBox', 'Eccentricity');<br><br>% Extract endpoints based on morphological skeleton<br>crack_skeleton = bwmorph(enhanced_img, 'skel', Inf);<br>endpoint_map = bwlookup(crack_skeleton, [0 1; 1 0], 'distinct');<br>

Crack Angle Calculation

% Calculate primary orientation angles using least squares fitting<br>orientation_angles = zeros(length(region_stats), 1);<br>for i = 1:length(region_stats)<br>    % Sample points around the centroid<br>    sample_points = region_stats(i).Centroid + 50*[-1 1; 1 -1]*randn(2);<br>    % Calculate mean angle<br>    orientation_angles(i) = mean(atan2d(sample_points(:,2)-region_stats(i).Centroid(2), ...<br>        sample_points(:,1)-region_stats(i).Centroid(1)));<br>end<br>

Crack Growth Splicing Algorithm

Distance-Angle Constraint Model

% Define growth parameters<br>max_endpoint_distance = 30; % Maximum allowed endpoint distance<br>angle_tolerance = 20; % Angular deviation tolerance<br><br>% Construct adjacency matrix<br>num_regions = length(region_stats);<br>adjacency_matrix = zeros(num_regions);<br>for i = 1:num_regions<br>    for j = i+1:num_regions<br>        % Calculate distance between centroids<br>        centroid_distance = norm(region_stats(i).Centroid - region_stats(j).Centroid);<br>        % Calculate angular difference<br>        angular_difference = min(abs(orientation_angles(i)-orientation_angles(j)), ...<br>            180-abs(orientation_angles(i)-orientation_angles(j)));<br>        % Check constraints<br>        if centroid_distance < max_endpoint_distance && angular_difference < angle_tolerance<br>            adjacency_matrix(i,j) = 1;<br>        end<br>    end<br>end<br><br>% Region growing algorithm<br>visited_nodes = false(num_regions,1);<br>final_merged = zeros(size(enhanced_img));<br><br>for i = 1:num_regions<br>    if ~visited_nodes(i)<br>        growth_queue = i;<br>        current_region = [];<br>        while ~isempty(growth_queue)<br>            current_node = growth_queue(1);<br>            growth_queue(1) = [];<br>            if ~visited_nodes(current_node)<br>                visited_nodes(current_node) = true;<br>                current_region = [current_region; current_node];<br>                <br>                % Get neighboring nodes<br>                neighbor_nodes = find(adjacency_matrix(current_node,:) & ~visited_nodes);<br>                growth_queue = [growth_queue; neighbor_nodes];<br>            end<br>        end<br>        <br>        % Merge region components<br>        region_mask = false(size(enhanced_img));<br>        for k = current_region<br>            region_mask = region_mask | imdilate(enhanced_img(:,:,k), strel('square',3));<br>        end<br>        final_merged = final_merged | region_mask;<br>    end<br>end<br>

Post-processing Optimization

Morphological Optimization

% Remove small region noise<br>cleaned_result = bwareaopen(final_merged, 50);<br><br>% Apply edge smoothing<br>smoothed_result = imgaussfilt(double(cleaned_result), 1.5);<br>

Result Visualization

figure;<br>subplot(131); imshow(binary_img); title('Original Binary Image');<br>subplot(132); imshow(enhanced_img); title('Enhanced Image');<br>subplot(133); imshow(cleaned_result); title('Splicing Result');<br>

Engineering Application Suggestions

  1. Hardware Acceleration Solutions
    • Utilize CUDA parallel computing to accelerate the region growing process
    • Implement morphological operations pipeline using FPGA
  2. Real-time Processing Optimization
    % GPU acceleration code example<br>gpu_image = gpuArray(enhanced_img);<br>gpu_mask = gpuArray(mask);<br>merged_gpu = arrayfun(@(x,y) bitxor(x,y), gpu_image, gpu_mask);<br>
  3. Cross-scale Fusion Strategy
    • Apply wavelet transform to decompose multi-scale features
    • Perform independent growing at different scales followed by weighted fusion

The algorithm intelligently splices cracks by integrating geometric features with topological relationships in a MATLAB environment.

Tags: Crack Detection Image Processing morphological operations region growing binary image analysis

Posted on Mon, 10 Aug 2026 16:35:08 +0000 by AsiaUnderworld