I new to matlab and image analysis. I want to measure average width (also min and max width) and and area of this probe. can anyone help me how to do this? thanks.

조회 수: 3 (최근 30일)
I want to measure this Image

답변 (1개)

yanqi liu
yanqi liu 2021년 10월 15일
sir,please check the follow code to get some information
clc; clear all; close all;
img = imread('https://ww2.mathworks.cn/matlabcentral/answers/uploaded_files/767536/Diameter21.jpg');
im = rgb2gray(img);
bw = imbinarize(im,'adaptive','ForegroundPolarity','dark','Sensitivity',0.6);
bw = imclose(bw, strel('line', 19, 90));
bw = bwareaopen(bw, 2000);
[L,num]=bwlabel(bw);
stats = regionprops(L);
ar = cat(1, stats.Area);
[~,ind] = sort(ar);
bw = L==ind(1)|L==ind(2);
im1 = im; im2 = im; im3 = im;
im1(bw) = 255; im2(bw) = 0; im3(bw) = 0;
imt = cat(3,im1,im2,im3);
figure; imshow(bw);
figure; imshow(imt);
% width
wid = [];
for i = 1 : size(bw,1)
ri = bw(i,:);
indi = find(ri);
wid(i) = indi(end)-indi(1);
end
% max、min、average
max_width = max(wid)
max_width = 329
min_width = min(wid)
min_width = 295
average_width = mean(wid)
average_width = 305.8774
  댓글 수: 1
Dinesh Dhameliya
Dinesh Dhameliya 2021년 10월 22일
thanks for your valable time and answer. but this code is working on only on upper Image but for other Images not working. I uploded image here. And above mentioned book is available in English?
thanks again.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Read, Write, and Modify Image에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by