MCPcopy Create free account
hub / github.com/MITK/MITK / GetVolumeForLabel

Method GetVolumeForLabel

Modules/AlgorithmsExt/src/mitkLabeledImageToSurfaceFilter.cpp:341–360  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

339}
340
341mitk::ScalarType mitk::LabeledImageToSurfaceFilter::GetVolumeForLabel(
342 const mitk::LabeledImageToSurfaceFilter::LabelType &label)
343{
344 // get the image spacing
345 mitk::Image *image = (mitk::Image *)GetInput();
346 const mitk::Vector3D spacing = image->GetSlicedGeometry()->GetSpacing();
347
348 // get the number of voxels encountered for the given label,
349 // calculate the volume and return it.
350 auto it = m_AvailableLabels.find(label);
351 if (it != m_AvailableLabels.end())
352 {
353 return static_cast<float>(it->second) * (spacing[0] * spacing[1] * spacing[2] / 1000.0f);
354 }
355 else
356 {
357 itkWarningMacro("Unknown label encountered: " << label);
358 return 0.0;
359 }
360}

Callers 1

Calls 4

GetSlicedGeometryMethod · 0.80
GetSpacingMethod · 0.45
findMethod · 0.45
endMethod · 0.45

Tested by 1