extracting area of cracks from image
3 views (last 30 days)
Show older comments
Dear all, I wrote this code to extract cracks from a tomography image. I tried many ways to remove the background and enhance the colors for better crack extraction, but some cracks are still missing. Can anyone help me improve the code?
clear all
close all
clc
A= imread('image_1567.png');
[rows, columns, numberOfColorChannels] = size(A);
[centers,radii] = imfindcircles(A,[500 650],Sensitivity=0.95);
mask = circles2mask(centers,radii,size(A));
new_image = A;
new_image(~mask) = nan;
figure(1)
sigma = 20;
Iflatfield = imflatfield(new_image,sigma);
imshow(Iflatfield)
figure(2)
imhist(Iflatfield);
figure(3)
crackMask = Iflatfield < 50;
imshow(crackMask)
0 Comments
Accepted Answer
Deepak
on 19 Jul 2024
Hi,
As I can understand you are trying to extract cracks from a tomography image. You tried several ways to enhance the colours of image, but some some cracks are still missing.
For better crack extraction from the image, you can perform following changes in your code –
1. Enhance contrast using adaptive histogram equalization
A = adapthisteq(A);
2. Apply Gaussian smoothing to reduce noise
A = imgaussfilt(A, 2);
3. Set the threshold value to 52 for better results
Here is the updated code snippet –
clear all
close all
clc
A= imread('image_1567.png');
A = adapthisteq(A);
A = imgaussfilt(A, 2);
[rows, columns, numberOfColorChannels] = size(A);
[centers,radii] = imfindcircles(A,[500 650],Sensitivity=0.95);
mask = circles2mask(centers,radii,size(A));
new_image = A;
new_image(~mask) = nan;
figure(1)
sigma = 20;
Iflatfield = imflatfield(new_image,sigma);
imshow(Iflatfield)
figure(2)
imhist(Iflatfield);
figure(3)
crackMask = Iflatfield < 52;
imshow(crackMask)
Attaching the documentation of above used functions for reference -
0 Comments
More Answers (1)
Rahul
on 19 Jul 2024
Hi @Elisa
In addition to your provided code to extract areas including cracks from the given image, you can make use of image processing techniques like Adaptive Histogram Equalization and Median Filtering to enhance the contrast of the image to better identify the crack areas.
You can do this by using 'adapthisteq' and 'medfilt2' functions respectively.
You can refer to this link to know more about their functionalities:
You might also consider tweaking the threshold value that you have defined as 50. This can help you get your desired result.
Hope this helps!
0 Comments
See Also
Categories
Find more on Biomedical Imaging in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!