Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Matlab 连通区域面积_Matlab_Image Processing - Fatal编程技术网

Matlab 连通区域面积

Matlab 连通区域面积,matlab,image-processing,Matlab,Image Processing,我有一个二值图像,我想从中手动测量连接的白色区域的面积,而不使用MATLAB函数。我已经标记了这些区域 I=imread('http://i.stack.imgur.com/rBaua.jpg') [Label,Total]=bwlabel(I,8); 标签是一个变量,从1:Total开始,将所有连接的白色区域分别标记。图为: .如果您不想使用任何内置函数,您可以轻松地在标签中循环并计算给定标签的像素数 areas = arrayfun(@(x)sum(Label(:) == x), 1:ma

我有一个二值图像,我想从中手动测量连接的白色区域的面积,而不使用MATLAB函数。我已经标记了这些区域

I=imread('http://i.stack.imgur.com/rBaua.jpg')
[Label,Total]=bwlabel(I,8);
标签是一个变量,从1:Total开始,将所有连接的白色区域分别标记。图为:


.

如果您不想使用任何内置函数,您可以轻松地在标签中循环并计算给定标签的像素数

areas = arrayfun(@(x)sum(Label(:) == x), 1:max(Label(:)));
或者,您也可以使用类似于
accumarray
histcounts
的方法来为您计数

areas = accumarray(Label(:)+1, Label(:), [], @numel);
areas = histcounts(Label(:), 1:max(Label(:)));