用Matlab计算一幅二值图像中目标的面积(也就是像素数表示),如何计算?

学习 时间:2026-04-03 14:47:18 阅读:6300
用Matlab计算一幅二值图像中目标的面积(也就是像素数表示),如何计算?图像是c我用的是bwarea(c)函数,计算出的像素数是1760个但是用 >>[l,num]=bwlabel(c); >>stats=regionprops(l,'Area'); >> A=stats.Area;计算出的是1710个,我想知道为什么两个计算结果不一样呢,差了50个像素呢,

最佳回答

活力的银耳汤

英俊的爆米花

2026-04-03 14:47:18

sum(c(:))试一下。我猜结果应该是1710。
你doc bwarea看一下,有下面这些话
total = bwarea(BW)
Description
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 might not be exactly the same because different
patterns of pixels are weighted differently****。

最新回答共有2条回答

  • 隐形的冬天
    回复
    2026-04-03 14:47:18

    sum(c(:))试一下。我猜结果应该是1710。你doc bwarea看一下,有下面这些话total = bwarea(BW)Descriptiontotal = bwarea(BW) estimatesthe area of the objects in binary image BW。 total isa scalar whose value corresponds roughly to the total number of on pixelsin the image, ****but might not be exactly the same because differentpatterns of pixels are weighted differently****。

上一篇 2x的三次方+4x-三分之一x的平方-(x+3x的平方-2x的三次方),其中x=负三

下一篇 南昌哪里买办公家具好