フィルターのクリア

Image processing for crack detection and length estimation

60 ビュー (過去 30 日間)
BB BSB
BB BSB 2015 年 4 月 9 日
コメント済み: Image Analyst 2023 年 5 月 12 日
Hi, I have written the following matlab code to do the following:-
  • load rgb image of surface
  • contrast stretch
  • convert rgb to gray scale
  • image segmentation
  • morphological operations (thin, clean , fill, etc...)
  • imtool for pixel length determination
  • Calculation of crack length based on calibration of image and above determined pixel lenght.
My aim is to develop the SIMPLEST matlab code for automatic detection of cracks and estimate the length of the crack (if possible other geometrical properties) from a sample image.
The code is shown below:
%%load image
I=imread('two.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
%use incremental value to run this selection till required threshold 'level' is
%achieved
level = 0.08;
Ithres = im2bw(Igray_h,level);
figure,imshow(Ithres)
title('Segmented cracks')
%%Image morphological operation
BW = bwmorph(gradmag,'clean',10);
figure,imshow(BW)
title('Cleaned image')
BW = bwmorph(gradmag,'thin', inf);
figure,imshow(BW)
title('Thinned image')
BW = imfill(gradmag, 'holes')
figure,imshow(BW)
title('Filled image')
%%Image tool
figure,imtool(BW1)
figure,imtool(I)
%%Calaculate crack length
calibration_length=0.001;
calibration_pixels=1000;
crack_pixel=35;
crack_length=(crack_pixel *calibration_length)/calibration_pixels;
Please, I need help from image specialist to improve the code from above to meet my aim. I have also attached a sample picture that I am using for this code.
Picture two.jpg is attached below:
Thanks
  3 件のコメント
Hari krishna
Hari krishna 2019 年 11 月 3 日
Could someone please help me to measure the crack and sketch a line on a diagram .
Image Analyst
Image Analyst 2019 年 11 月 3 日
We'll try, after you've read this link

サインインしてコメントする。

採用された回答

Image Analyst
Image Analyst 2015 年 4 月 9 日
You're just arbitrarily setting
crack_pixel=35;
You're not even doing it manually (with user assistance) - you're just setting some arbitrary number. What's up with that? If you need code to find the distance between the farthest points in a binary blob, see my attached demo.
  15 件のコメント
Pilli Lalvinnu
Pilli Lalvinnu 2022 年 5 月 7 日
ma'am I am doing the same project. I would reaaly appreciate it if you could help me out!
Image Analyst
Image Analyst 2022 年 5 月 7 日
@Pilli Lalvinnu, sure. What sort of help do you need? I'm assuming you started with the solutions given here but they didn't work for your image(s) so start a new question with your code and images attached, and ask a specific question and we'll help.

サインインしてコメントする。

その他の回答 (5 件)

Dan
Dan 2015 年 4 月 13 日
I just glanced at your code and if you need a completely automated system, you need to either define what constitutes a crack beforehand OR have the system learn these rules using something like a neural net.
But... that's a bigger project. In the short term, you might want to play with the graythresh function that will automate your selection of a threshold.
Just my $0.02.
Dan
  1 件のコメント
BB BSB
BB BSB 2015 年 4 月 14 日
編集済み: BB BSB 2015 年 4 月 14 日
I see, for timeline limits Id rather attempt the easier of the 3 methods you outlined which I guess is playing around with graythresh function.
Any hints as to how or what to look out for in doing so? Because my first approach would be to scale by a factor??? make any sense? Thanks.

サインインしてコメントする。


Yashwanth G M
Yashwanth G M 2019 年 3 月 25 日
Sir help me to find out the area of a solar panel interms of Sq.mm....
  1 件のコメント
Image Analyst
Image Analyst 2019 年 3 月 25 日
Then post a new Question, not an Answer to BB's question.

サインインしてコメントする。


Ram kumar R
Ram kumar R 2020 年 2 月 12 日
i got error in line no.21 as Ithres = im2bw(Igray_h,level) can u explain it ?
  4 件のコメント
Ayoub MOSSLIH
Ayoub MOSSLIH 2021 年 2 月 28 日
Undefined function or variable 'gradmag'.
Error in Untitled (line 30)
BW = bwmorph(gradmag,'clean',10);
Image Analyst
Image Analyst 2021 年 2 月 28 日
@Ayoub MOSSLIH, we have no idea what code you ran. Please start a new question and attach your image and m-file there.

サインインしてコメントする。


Image Analyst
Image Analyst 2021 年 1 月 2 日
See my attached demo that computes both the tortuosity and mean width.
  10 件のコメント
AMAR SAISH
AMAR SAISH 2023 年 1 月 2 日
sir, i have done image segmentation for crack images. Now, i want to find the length and width of crack, so i should use this code on original images or segmented images ??
Image Analyst
Image Analyst 2023 年 1 月 2 日
@AMAR SAISH, the segmented images.

サインインしてコメントする。


Meherunnisa
Meherunnisa 2023 年 5 月 12 日
%%load image
I=imread('two.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 %use incremental value to run this selection till required threshold 'level' is %achieved
level = 0.08; Ithres = im2bw(Igray_h,level); figure,imshow(Ithres) title('Segmented cracks')
%%Image morphological operation
BW = bwmorph(gradmag,'clean',10); figure,imshow(BW) title('Cleaned image')
BW = bwmorph(gradmag,'thin', inf); figure,imshow(BW) title('Thinned image')
BW = imfill(gradmag, 'holes') figure,imshow(BW) title('Filled image')
%%Image tool
figure,imtool(BW1) figure,imtool(I)
%%Calaculate crack length
calibration_length=0.001; calibration_pixels=1000; crack_pixel=35;
crack_length=(crack_pixel *calibration_length)/calibration_pixels;
  1 件のコメント
Image Analyst
Image Analyst 2023 年 5 月 12 日
Your crack length computation does not even look at any measurements from the image. It just uses arbitrary values hard coded in.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeImage Processing Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by