|
a |
|
b/Thoracic Organs Segmentation code/DrawCircle.m |
|
|
1 |
function [Img] = DrawCircle(R,c1,c2,x,y,lineWidth); |
|
|
2 |
Img = zeros(x,y); |
|
|
3 |
theta = [0 : 0.01 : 2 * pi]; |
|
|
4 |
stack1 = 0; |
|
|
5 |
if nargin == 5 |
|
|
6 |
|
|
|
7 |
lineWidth = 1; |
|
|
8 |
end |
|
|
9 |
for i = 1 : length( theta ) |
|
|
10 |
|
|
|
11 |
temp_x = 0; temp_y = 0; |
|
|
12 |
|
|
|
13 |
temp_x =ceil( R* cos (theta(i)) + c1); |
|
|
14 |
|
|
|
15 |
temp_y = ceil (R* sin (theta(i)) + c2); |
|
|
16 |
stack1 = stack1 + 1; |
|
|
17 |
I_new(stack1) = temp_x ; |
|
|
18 |
J_new(stack1) = temp_y ; |
|
|
19 |
Img( temp_x , temp_y ) = 1; |
|
|
20 |
|
|
|
21 |
%plot(I_new,J_new,'.',c1,c2,'r*') |
|
|
22 |
end |
|
|
23 |
|
|
|
24 |
se1 = strel('line',lineWidth,0); |
|
|
25 |
se2 = strel('line',lineWidth,90); |
|
|
26 |
Img = imdilate(Img,[se1 se2],'same'); |