Matlab code for wall crack detection

조회 수: 17 (최근 30일)
mohammed sharique
mohammed sharique 2017년 3월 14일
편집: Preetham Manjunatha 2025년 5월 16일
can anyone please tell me the code for line detection technique of a wall crack and how to analyse the crack after a certain width. thank you

답변 (4개)

Image Analyst
Image Analyst 2017년 3월 14일
Try thresholding. Or else look for asphalt or concrete. It's been asked before. Or else try http://www.visionbib.com/bibliography/contents.html

shivani verma
shivani verma 2019년 10월 17일
i am also working on this poject soon i am going to share the process and progress of this project
  댓글 수: 3
roni oz
roni oz 2021년 6월 11일
Hi
I'm doing work on this subject.
I would be happy if you could share the process for me too.
Thanks,
Roni

댓글을 달려면 로그인하십시오.


Image Analyst
Image Analyst 2020년 11월 15일
One way to do it is to threshold the cracks to find a binary image. Then call regionprops to get the area and perimeter. Assuming that the cracks are long and skinny, you can estimate that area = length*width, and perimeter = 2*(length+width). From that you get width = area/(length) = area / (2*(length+width)). So now solve the quadratic equation for width.
Another way is to skeletonize the binary image, then take it's skeleton with bwskel(). Then compute the Euclidean distance with bwdist() and multiply. The values in the image will be the radii along the spine of the crack. Double it to get the mean width (diameter). You can then get a histogram of widths, or simply take the mean of non-zero values to get the overall mean width.
% Program to compute the mean width of a blob in an image. By Image Analyst.
clearvars;
close all;
clc;
fontSize = 15;
% Read in original image, with white lightning on black background.
baseFileName = 'mean_width_of_blob.png';
fullFileName = fullfile(pwd, baseFileName);
grayImage = imread(fullFileName);
% Get the dimensions of the image.
% numberOfColorChannels should be = 1 for a gray scale image, and 3 for an RGB color image.
[rows, columns, numberOfColorChannels] = size(grayImage)
if numberOfColorChannels > 1
% It's not really gray scale like we expected - it's color.
% Use weighted sum of ALL channels to create a gray scale image.
% grayImage = rgb2gray(rgbImage);
% ALTERNATE METHOD: Convert it to gray scale by taking only the green channel,
% which in a typical snapshot will be the least noisy channel.
grayImage = grayImage(:, :, 2); % Take green channel.
else
grayImage = grayImage; % It's already gray scale.
end
% Now it's gray scale with range of 0 to 255.
subplot(2, 3, 1);
imshow(grayImage, [])
impixelinfo; % Let user mouse around and see values in the status line at the lower right.
title('Original Image', 'FontSize', fontSize);
% Binarize the image.
mask = imbinarize(grayImage);
% Fill holes.
mask = imfill(mask, 'holes');
% Take largest blob only.
mask = bwareafilt(mask, 1);
subplot(2, 3, 2);
imshow(mask)
impixelinfo; % Let user mouse around and see values in the status line at the lower right.
title('Mask', 'FontSize', fontSize)
% Compute the skeleton
skelImage = bwskel(mask);
subplot(2, 3, 3);
imshow(skelImage)
impixelinfo; % Let user mouse around and see values in the status line at the lower right.
title('Thinned', 'FontSize', fontSize)
% Enlarge figure to full screen.
g = gcf;
g.WindowState = 'maximized';
% Compute the Euclidean distance image.
edtImage = bwdist(~mask);
subplot(2, 3, 4);
imshow(edtImage, [])
title('Distance Transform Image', 'FontSize', fontSize);
impixelinfo; % Let user mouse around and see values in the status line at the lower right.
% Multiply them to get an image where the only pixels in the image
% are along the skeleton and their value is the radius.
% Multiply radius image by 2 to get diameter image.
diameterImage = 2 * edtImage .* single(skelImage);
subplot(2, 3, 5);
imshow(diameterImage, [])
title('Diameter Image', 'FontSize', fontSize);
impixelinfo; % Let user mouse around and see values in the status line at the lower right.
% Get the widths. These will be where the image is not zero.
widths = diameterImage(diameterImage > 0);
% Show histogram of widths.
subplot(2, 3, 6);
histogram(widths);
grid on;
xlabel('Width in Pixels', 'FontSize', fontSize);
ylabel('Count', 'FontSize', fontSize);
% Compute the mean width
meanWidth = mean(widths)
% Put a line on the histogram at the mean width
xline(meanWidth, 'LineWidth', 2, 'Color', 'r');
caption = sprintf('Histogram of Widths. Mean Width = %.1f Pixels', meanWidth);
title(caption, 'FontSize', fontSize);
message = sprintf('Mean Width = %.1f Pixels', meanWidth);
msgbox(message);

Preetham Manjunatha
Preetham Manjunatha 2024년 12월 19일
편집: Preetham Manjunatha 2025년 5월 16일
Here is the MATLAB Crack segmentation and Crack width, length and area estimation codes to calculate/estimate the crack area, width and length. In addition, this package assumes the crack is segmented either using morphological method or multiscale gradient-based or deep learning semantic segmentation methods. This package estimates the crack area, width and length (pixel scale can be provided to estimate these physical quantities). Lastly, the semantic segmentation and object detection metrics for the cracks can be found using Cracks binary class bounding box and segmentation metrics package.

카테고리

Help CenterFile Exchange에서 Image Segmentation and Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by