# [Insight-users] How to calculate a volume

Luis Ibanez luis.ibanez at kitware.com
Fri Feb 5 13:58:37 EST 2010

```Hi Xi,

You could use:

1) StatisticsImageFilter
and call GetSum()

and then multiply by the pixel volume,
as Marius suggested.

or

2)  itkLabelStatisticsImageFilter.h
and call GetCount()

and then multiply by the pixel volume,
as Marius suggested.

or

3)  itkImageMomentsCalculator.h
and call GetTotalMass(), then divide
by the label value of the mask, and
multiply by the pixel volume

OR

4)   itkLabelGeometryImageFilter.h
can call GetVolume( label )
where "label" is the label value

For this option you may find useful to

*  "A Label Geometry Image Filter for Multiple Object Measurement"
*  by Padfield D., Miller J
*  http://www.insight-journal.org/browse/publication/301
*  http://hdl.handle.net/1926/1493

OR

5)  Use itkShapeLabelMapFilter.txx

and in the output itkShapeLabelObject,
call:

GetPhysicalSize().

For this option you will find useful to
read the following Insight Journal paper:

http://hdl.handle.net/1926/584
http://www.insight-journal.org/browse/publication/176
by Gaetan Lehmann.
Biologie du Developpement et de la Reproduction,
INRA de Jouy-en-Josas, France.

Regards,

Luis

----------------------------------
On Tue, Feb 2, 2010 at 4:33 AM,  <M.Staring at lumc.nl> wrote:
> Hi Xi,
>
> you can multiply the number of voxels that you found by the number of ml
> of one voxel, which is the product of the gridspacing:
>
> SpacingType spacing = image->GetSpacing();
> double volumeOfOneVoxel = spacing[0] * spacing[1] * spacing[2];
> double totalVolume = nrOfVoxelsInMask * volumeOfOneVoxel;
>
> Regards,
>
> Marius
>
>> -----Original Message-----
>> From: insight-users-bounces at itk.org
>> [mailto:insight-users-bounces at itk.org] On Behalf Of Xi LIANG
>> Sent: dinsdag 2 februari 2010 9:54
>> To: Insight Users
>> Cc: Xi LIANG
>> Subject: [Insight-users] How to calculate a volume
>>
>> Dear all,
>>
>> I am trying to calculate the volume of a 3D mask image. What
>> I did was to count the voxel number, but found some image
>> have different voxel space. Therefore, I think I should
>> calculate them in ml. Is there any example available to
>> calculate the volume? All suggestions are welcome.
>>
>> Best regards,
>>
>> Xi
>>
>>
>>
>>
>> ________________________________
>>
>> Hotmail: Powerful Free email with security by Microsoft. Get
>> it now. <https://signup.live.com/signup.aspx?id=60969>
>>
> _____________________________________
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>