Effacer les filtres
Effacer les filtres

Crack analysis and width measurement in Concrete

45 vues (au cours des 30 derniers jours)
Ashutosh le 1 Mar 2024
i want the measurement of the crack in the concrete here is my code for my image2.jpg which i am using it shows two measurement but i think the meaurements are wrong can anyone please corrrect the code or suggest the better method for that.
close all;
%% Load image
I = imread('image2.jpg');
figure, imshow(I)
title('Original image')
%% Image adjust
Istrech = imadjust(I, stretchlim(I));
figure, imshow(Istrech)
title('Contrast stretched image')
%% Convert RGB image to gray
Igray_s = rgb2gray(Istrech);
figure, imshow(Igray_s, [])
title('RGB to gray (contrast stretched) ')
%% Image segmentation by thresholding
level = 0.08;
Ithres = imbinarize(Igray_s, level);
figure, imshow(Ithres)
title('Segmented image of the cracks')
%% Label connected components
bw = bwareaopen(Ithres, 50); % Remove small noise regions
[L, num] = bwlabel(bw);
%% Measure properties
stats = regionprops(L, 'MajorAxisLength', 'MinorAxisLength', 'Area', 'Centroid');
%% Calculate crack length
calibration_length = 1;
calibration_pixels = 1000;
crack_length = zeros(num, 1);
for i = 1:num
% Calculate crack length using major axis length
crack_length(i) = stats(i).MajorAxisLength * calibration_length / calibration_pixels;
% Display crack lengths
disp('Crack Lengths:')
% Display segmented image with crack lengths
figure, imshow(Ithres)
hold on
for i = 1:num
text(stats(i).Centroid(1), stats(i).Centroid(2), num2str(crack_length(i)), 'Color', 'red', 'FontSize', 10);
hold off
title('Segmented cracks with length')
% Display segmented image with crack lengths
figure, imshow(I)
hold on
for i = 1:num
bb = stats(i).BoundingBox;
rectangle('Position', [bb(1), bb(2), bb(3), bb(4)], 'EdgeColor', 'r', 'LineWidth', 2);
hold off
title('Highlighted cracks')

Réponses (2)

akshatsood le 5 Mar 2024
Modifié(e) : akshatsood le 5 Mar 2024
I understand you are aiming to analyze and measure cracks in concrete but are encountering issues with the accuracy of your results. Upon reviewing your code, I have identified several areas for improvement that could enhance the efficiency and precision of your analysis.
  1. Calibration Factor: Your calibration factor (calibration_length / calibration_pixels) might not be accurate for your specific image. Ensure that this factor correctly represents the real-world length of a pixel in your image. This is a common source of error in measurements from images.
  2. Image Preprocessing: The quality of the original image and the preprocessing steps can affect the outcome. Ensure that the contrast stretching and thresholding effectively highlight the cracks without introducing noise or omitting parts of the cracks.
  3. Thresholding Level: you might adjust the threshold level (level = 0.08) for binarization based on the histogram of your grayscale image to better segment the cracks.
  4. Noise Removal: The "bwareaopen" function is used to remove small objects from the binary image. The parameter "50" might not be optimal for your case, adjusting this value can help in removing noise or preserving important features.
  5. Measurement Method: using the "MajorAxisLength" property to estimate crack length can be effective, however, it might not always provide an accurate representation of the actual crack length, especially if the crack is not straight. Consider using a more sophisticated method to trace and measure the crack length, such as skeletonization followed by measuring the skeleton's length.
If you are keen on exploring crack detection in greater depth, consider going through the research paper titled "Crack Detection of Wall Using MATLAB". This paper outlines a comprehensive approach to crack detection using MATLAB.. For a thorough understanding of their techniques and insights, access the full text via the following link:
Additionally, I recommend reviewing the following threads to gain insights into various approaches for crack detection. These discussions can provide valuable intuition and perspectives on different methodologies.
  1. https://in.mathworks.com/matlabcentral/answers/329846-matlab-code-for-wall-crack-detection#answer_545173
  2. https://in.mathworks.com/support/search.html/answers/593341-how-to-detect-the-crack-and-calculate-its-length.html
  3. https://in.mathworks.com/support/search.html/answers/196886-image-processing-for-crack-detection-and-length-estimation.html
I hope this helps.

Image Analyst
Image Analyst le 6 Mar 2024
I'm pretty sure I've done this several times before. Look up tags concrete, crack, etc. and see what answers of mine pop up. I can tell the code you're using is not mine, for example it does contrast stretching which is not necessary.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by