我有一个骨架图像。如以下链接所示。
http://www.flickr.com/photos/92388309@N03/8397759970/in/photostream/
我已经检测到分支点和端点并标记了图像。现在我在每个分支上画一个圆圈,我正在使用以下代码在每个分支上画一个圆圈。
mn=bwmorph(y,'branchpoints');
[row column] = find(mn);
branchPts = [row column];
endImg = bwmorph(y, 'endpoints');
[row column] = find(endImg);
endPts = [row column];
figure;imshow(y);
hold on ;
plot(branchPts(:,2),branchPts(:,1),'rx');
hold on; plot(endPts(:,2),endPts(:,1),'*');
% Labeling the Branches
branches = (y & ~mn); % set branch points to zero
figure; imshow(branches);
branchesLabeled = bwlabel( branches); % label connected components
vislabels(branchesLabeled)
% Calculation of Length of Branches and Circular Neighbourhood Method for
% for detection of normal and abnormal branches.
sts = regionprops( branchesLabeled,'Area', 'Perimeter','MajorAxisLength','Centroid' );
% extract properties
% Loop for circles
for i=1:size(sts)
r= sts(i).MajorAxisLength/2 ; %desired radius
centerx = sts(i).Centroid(1);
centery = sts(i).Centroid(2);
th = 0:pi/50:2*pi;
xunit = r * cos(th) + centerx;
yunit = r * sin(th) + centery;
figure; imshow(branchesLabeled);hold on;h = plot(xunit, yunit);
end
这段代码我有几个问题。
圆圈画在骨架的中心线上(不是分支,是骨架的中心线) http://www.flickr.com/photos/92388309@N03/8402753918/in/photostream
这段代码给了我一些图像(每个分支一个)。我想在同一图像上的每个分支上画圈。
我想通过使用圆形邻域法(通过在每个分支上绘制圆圈并检查圆圈中有多少背景像素)来找到分支度