extract_region_reg.m

来自「mean shift」· M 代码 · 共 20 行

M
20
字号
function [Boundary, Area] = Extract_region (Image_given, Min_area)
% Extract_region - given Initial_value (a pixel close to the actual
% boundary of a segment), and Image containing the segment,
% outputs the supposed boundary of the piece (not necessarily connected)
% by finding the connected component containing the given point first,
% and finding the perimeter of the piece second

[Rows_i, Cols_i] = size(Image_given);
Enclosing = zeros(Rows_i+2, Cols_i+2);
Enclosing(2:Rows_i+1, 2:Cols_i+1) = Image_given;
Area = bwarea(Enclosing);
if Area < Min_area
	Boundary = 0;
	return;
end
Boundary = bwperim(Enclosing);
[Rows, Cols] = find(Boundary);
Boundary = [Rows'; Cols'];
Boundary = Boundary-ones(size(Boundary));

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?