Thickness measurements of an optical image

15 vues (au cours des 30 derniers jours)
Jason Deacon
Jason Deacon le 17 Mar 2022
Hello everyone,
I wanted to achieve an ambitious goal of automating thickness measurements. We had a 2D slice of our coating and I wanted to construct a baseline where coating meets steel and make a histogram of thickness measurements based on the colour of the pixels.
E.G. Draw a square of Width x above the baseline and increase Y until a threshold is met. The threshold could be when the pixels change HEX/RGB/HSL to an excluded list (e.g. too dark) or some simpler approach.
Image below highlights my goal, does anyone know of an easy way to do this or if there is a script already available?
Best wishes,
Dr. Deacon

Réponses (1)

yanqi liu
yanqi liu le 18 Mar 2022
im = imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/930819/image.png');
bw = im2bw(im);
bw2 = imclose(imfill(bw, 'holes'), strel('disk', 9));
bw3 = bwareafilt(bw2, 1, 'smallest');
bw = bwareaopen(imclearborder(~logical(bw.*bw3)), 5);
s = sum(bw, 2);
[~,id] = max(s);
% bw = imclose(bw, strel('line', 15, 0));
figure; imshow(bw, []); hold on; plot([1 size(bw,2)], [id id], 'r-');
figure; imshow(im, []);
hold on; plot([1 size(bw,2)], [id id], 'r-');
[r,c] = find(bw3);
cs = round(linspace(min(c), max(c), 30));
for i = 1 : length(cs)-1
bwi = zeros(size(bw3));
bwi(:, cs(i):cs(i+1)) = bw3(:, cs(i):cs(i+1));
[ri, ci] = find(bwi);
recti = [min(ci) min(ri) max(ci)-min(ci) id-min(ri)];
hold on; rectangle('position', recti, 'EdgeColor', 'g', 'LineWidth', 2)
end

Catégories

En savoir plus sur Images dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by