| 339 | } |
| 340 | |
| 341 | mitk::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 | } |