-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathm_boundray.m
49 lines (40 loc) · 1.35 KB
/
m_boundray.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
function [ n ] = m_boundray( marklabel,color, varargin )
%m_boundray Summary of this function goes here
% Detailed explanation goes here
% Delineate the boundary of the mask
% INPUT marklabel the mask
% color the color of the line
% varargin there can be one extra input setting the line
% width, the default line width is 1.5
% OUTPUT n number of connected objects in the mask
if nargin>2
line_width = varargin{1};
else
line_width = 1.5;%
end
if ~isstruct(marklabel)
[gn,n]=bwlabel(marklabel, 8);% the number of lesions is n
hold on
for i=1:n
testim=zeros(size(gn));
testim(gn==i)=1;
boundary= bwboundaries(testim);%
hold on
for k = 1:length(boundary)
plot(boundary{k}(:,2), boundary{k}(:,1),'Color',color, 'LineWidth', line_width);
end
end
else
n = marklabel.NumObjects;
for j = 1:marklabel.NumObjects
testim = zeros(marklabel.ImageSize);
testim(marklabel.PixelIdxList{j})=1;
boundary= bwboundaries(testim);%
hold on
for k = 1:length(boundary)
plot(boundary{k}(:,2), boundary{k}(:,1),color, 'LineWidth', line_width);
end
end
end
hold off
end