Thickness measurements of an optical image
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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
0 comentarios
Respuestas (1)
yanqi liu
el 18 de Mzo. de 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
0 comentarios
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!