Finding distance between endpoints of image segment: PixelList vs 'endpoints'
古いコメントを表示
New Code:
%%Calculate Tortuosity
disp('Calculating tortuosity of large segments');
V = thin8-imdilate(crosslinks,strel('disk',2));
V(V<=0) = 0; V(V>0) = 1; % return to binary
V = bwareaopen(V,3); % get rid of small segments
[K n] = bwlabel(V,8);
props = regionprops(K,'Perimeter');
tort = zeros(1,n);
endpts = bwmorph(V,'endpoints');
endpts_labeled = immultiply(K,endpts);
for m = 1:n
[rows,cols] = find(endpts_labeled==m);
if numel(rows) ~= 2
tort(m) = NaN;
else
p1 = [rows(1),cols(1)];
p2 = [rows(2),cols(2)];
d = sqrt((p1(1)-p2(1))^2+(p1(2)-p2(2))^2);
c = props(m,1).Perimeter/2;
tort(m) = c/d;
end
end
tort(isnan(tort)) = [];
tort_avg = mean(tort);
tort_std = std(tort);
Original Post:
I am working to find the tortuosity of about 500-1000 segments like this one:

They are randomly spaced throughout a larger image and have varying lengths and orientation. I am using a simple definition of tortuosity (tort = distance between endpoints/length of curve). I am getting an accurate reading of the curve length verified via Matlab Blog Post, but I am not sure if I am getting an accurate distance between the endpoints.
I am trying two different methods (using PixelList and the slower method of Endpoints), but neither method is giving me the exact number expected for some of the segments I spot checked and I was wondering which is the more accurate method for determining the euclidean distance of the segments endpoints. My code is as follows:
採用された回答
その他の回答 (1 件)
Thomas
2012 年 6 月 22 日
You could lockup the Medical Image processing webinar which deals with toruosity.. You could also try bwdistgeodesic command..
doc bwdist
doc bwdistgeodesic
カテゴリ
ヘルプ センター および File Exchange で High Dynamic Range Images についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!