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

Private GIT Repository
11 oct
[these_gilles.git] / THESE / codes / meanshift / Ms_segmenter / Extract_region_reg.m
1 function [Boundary, Area] = Extract_region (Image_given, Min_area)\r
2 % Extract_region - given Initial_value (a pixel close to the actual\r
3 % boundary of a segment), and Image containing the segment,\r
4 % outputs the supposed boundary of the piece (not necessarily connected)\r
5 % by finding the connected component containing the given point first,\r
6 % and finding the perimeter of the piece second\r
7 \r
8 [Rows_i, Cols_i] = size(Image_given);\r
9 Enclosing = zeros(Rows_i+2, Cols_i+2);\r
10 Enclosing(2:Rows_i+1, 2:Cols_i+1) = Image_given;\r
11 Area = bwarea(Enclosing);\r
12 if Area < Min_area\r
13         Boundary = 0;\r
14         return;\r
15 end\r
16 Boundary = bwperim(Enclosing);\r
17 [Rows, Cols] = find(Boundary);\r
18 Boundary = [Rows'; Cols'];\r
19 Boundary = Boundary-ones(size(Boundary));\r