Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

bwarea

17 views
Skip to first unread message

Mathew Thomas

unread,
Jul 13, 2010, 3:09:05 PM7/13/10
to
Hello All,

Can someone please explain how the "bwarea" command works ? It says that the value given is a rough estimate of the number of ON pixels. So if I have a binary image, and the number of ON or white pixels obtained using bwarea is 1800, how can I convert this into metric value if I know 1 pixel = 0.05 mm ?

Thanks in advance for any help.

Mathew

Jeff

unread,
Jul 13, 2010, 3:16:19 PM7/13/10
to
"Mathew Thomas" <math...@gmail.com> wrote in message <i1idkh$3om$1...@fred.mathworks.com>...

If 1 pixel = 0.05 mm on a side, then square it to get the area of a pixel = .0025 mm^2. Multiply that value by the number of pixels to get the area = 1.5 mm^2.

bwarea_count = bwarea(image);
real_area = bw_area_count * .0025;

----Jeff----

Jeff

unread,
Jul 13, 2010, 3:22:06 PM7/13/10
to
"Jeff " <j...@gene.dot.com> wrote in message <i1ie23$2b5$1...@fred.mathworks.com>...

Curse these fat fingers... total area = 4.5 mm^2

Mathew Thomas

unread,
Jul 13, 2010, 9:13:06 PM7/13/10
to
lol..Tnx Jeff

Cris Luengo

unread,
Jul 14, 2010, 6:38:05 AM7/14/10
to
"Mathew Thomas" <math...@gmail.com> wrote in message <i1idkh$3om$1...@fred.mathworks.com>...

I'm not replying to your question, you've already gotten a good answer. This is to warn you about the BWAREA. I don't know what it is optimized for, but just using SUM to count pixels is a better way to estimate the area of a binarized object. It is a well-known result that the "sum of ON pixels" is an unbiased estimate of area. The following script illustrates this:


figure,hold on
for jj=1:10
xx = (-128:127)+rand;
yy = (-128:127)+rand;
[xx,yy]=meshgrid(xx,yy);
rr = sqrt(xx.^2+yy.^2);
a = [];
for ii=1:25
r = ii*5;
m = rr<=r;
a(ii,1) = pi*r^2;
a(ii,2) = sum(m(:));
a(ii,3) = bwarea(m);
end
plot(a(:,1),a(:,2)-a(:,1))
plot(a(:,1),a(:,3)-a(:,1),'r')
end
plot(a([1,end],1),[0,0],'k:')
legend('sum=unbiased estimate','bwarea=biased estimate','Location','NorthWest')


Cheers,
Cris.

0 new messages