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
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
16 Boundary = bwperim(Enclosing);
\r
17 [Rows, Cols] = find(Boundary);
\r
18 Boundary = [Rows'; Cols'];
\r
19 Boundary = Boundary-ones(size(Boundary));
\r