Image processing for calculating length between two points on an image.
5 views (last 30 days)
Show older comments
Hello,
I am investigating a soltuion for calculating the width of cracks in lithium-ion batteries that have been damaged. I have CT scans of cross sections of the batteries, and I am looking to use MATLAB Image Processing Toolbox to calculate the width of the crack from these images.
So far, I have worked to isolate the battery casing from the image using some image processing functions, including segmenting the image with a global threshold and then retaining the object with the largest perimeter (the battery casing) using the bwpropfilt function. The code I have used for this is below.
I = imread('2D top view_310822_1238.jpg');
imshow(I)
title('Original CT Scan');
Igray = rgb2gray(I);
imshow(Igray)
Igray2 = imadjust(Igray);
imshow(Igray2)
BW = imbinarize(Igray2,"global");
imshow(BW)
BW2 = bwpropfilt(BW, 'perimeter', 1);
figure;
imshow(BW2)
I have also attached images of the original CT scan and the image BW2.
What I would now like to do is to calculate the point-to-point distance between the two ends of the battery casing. I have attached a third image, "Question_demonstration", to demonstrate this question.
Therefore, can somebody please suggest solutions to this problem?
0 Comments
Accepted Answer
Matt J
on 8 Feb 2024
Edited: Matt J
on 8 Feb 2024
load BW2
[I,J]=find(bwmorph(bwskel(BW2),'endpoints'));
[~,k]=mink(J,2);
d=norm([ diff(I(k)), diff(J(k))])
11 Comments
Matt J
on 9 Feb 2024
One of your example BW2s seems to be completely closed. Where are the endpoints needed to calculate d in this example,
imshow( load('300822_BW2.mat').BW2 )
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!