bwarea.m
来自「有关matlab的电子书籍有一定的帮助希望有用」· M 代码 · 共 39 行
M
39 行
function a = bwarea(b)
%BWAREA Compute the area of objects in binary image.
% TOTAL = BWAREA(BW) estimates the area of the objects in
% binary image BW. TOTAL is a scalar whose value corresponds
% roughly to the total number of "on" pixels in the image, but
% may not be exactly the same because different patterns of
% pixels are weighted differently.
%
% Class Support
% -------------
% BW can be of class uint8 or double. TOTAL is of class
% double.
%
% Example
% -------
% BW = imread('circles.tif');
% imshow(BW)
% bwarea(BW)
%
% See also BWPERIM, BWEULER.
% Clay M. Thompson 11-17-92
% Revised Steven L. Eddins, 1996
% Copyright 1993-1998 The MathWorks, Inc. All Rights Reserved.
% $Revision: 5.8 $ $Date: 1997/11/24 15:34:04 $
% Reference: William Pratt, Digital Image Processing, John Wiley
% and Sons, 1991, pp. 630-634.
lut = [0 2 2 4 2 4 6 7 2 6 4 7 ...
4 7 7 8];
% Need to zero-pad the input.
bb = repmat(uint8(0),size(b)+2);
bb(2:end-1,2:end-1) = b;
weights = applylut(bb,lut);
a = sum(weights(:))/8;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?