extracting area of cracks from image

7 次查看(过去 30 天)
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)

采纳的回答

Deepak
Deepak 2024-7-19
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 -

更多回答(1 个)

Rahul
Rahul 2024-7-19
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!

类别

Help CenterFile Exchange 中查找有关 Biomedical Imaging 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by