]> AND Private Git Repository - these_gilles.git/blob - THESE/codes/meanshift/Ms_segmenter/Neighbor.m
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
07 sep
[these_gilles.git] / THESE / codes / meanshift / Ms_segmenter / Neighbor.m
1 function Answer = Neighbor(Region1, Region2)\r
2 \r
3 Min_x = min(Region1.Shifts(1, 1), Region2.Shifts(1, 1));\r
4 Max_x = max(Region1.Shifts(1, 2), Region2.Shifts(1, 2));\r
5 Min_y = min(Region1.Shifts(2, 1), Region2.Shifts(2, 1));\r
6 Max_y = max(Region1.Shifts(2, 2), Region2.Shifts(2, 2));\r
7 \r
8 Image1 = zeros(Max_x-Min_x+3, Max_y-Min_y+3);\r
9 Image1(sub2ind(size(Image1), Region1.Boundary(1, :)-Min_x+2, ...\r
10                 Region1.Boundary(2, :)-Min_y+2)) = 1;\r
11 Image1 = double(bwmorph(Image1, 'thicken'));\r
12 Image2 = zeros(Max_x-Min_x+3, Max_y-Min_y+3);\r
13 Image2(sub2ind(size(Image2), Region2.Boundary(1, :)-Min_x+2, ...\r
14                 Region2.Boundary(2, :)-Min_y+2)) = 1;\r
15 Image2 = double(bwmorph(Image2, 'thicken'));\r
16 \r
17 Image1 = Image1+Image2;\r
18 \r
19 if length(find(Image1>1))>0             % there are some points with value of 2\r
20         Answer = 1;\r
21 else\r
22         Answer = 0;\r
23 end\r