| 239 | } |
| 240 | |
| 241 | mitk::Image::Pointer mitk::ConvertImageToGroupImage(const Image* inputImage, mitk::MultiLabelSegmentation::LabelValueVectorType& foundLabels) |
| 242 | { |
| 243 | if (nullptr == inputImage || inputImage->IsEmpty() || !inputImage->IsInitialized()) |
| 244 | mitkThrow() << "Invalid labeled image."; |
| 245 | |
| 246 | auto result = Image::New(); |
| 247 | result->Initialize(mitk::MakePixelType<mitk::MultiLabelSegmentation::LabelValueType, mitk::MultiLabelSegmentation::LabelValueType, 1>(), *(inputImage->GetTimeGeometry())); |
| 248 | |
| 249 | try |
| 250 | { |
| 251 | if (result->GetDimension() == 3) |
| 252 | { |
| 253 | AccessFixedDimensionByItk_2(inputImage, ConvertImageToGroupImageInternal, 3, result, foundLabels); |
| 254 | } |
| 255 | else if (result->GetDimension() == 4) |
| 256 | { |
| 257 | AccessFixedDimensionByItk_2(inputImage, ConvertImageToGroupImageInternal, 4, result, foundLabels); |
| 258 | } |
| 259 | else |
| 260 | { |
| 261 | mitkThrow() << result->GetDimension() << "-dimensional group images not yet supported"; |
| 262 | } |
| 263 | } |
| 264 | catch (Exception& e) |
| 265 | { |
| 266 | mitkReThrow(e) << "Could not initialize by provided labeled image."; |
| 267 | } |
| 268 | catch (...) |
| 269 | { |
| 270 | mitkThrow() << "Could not initialize by provided labeled image due to unknown error."; |
| 271 | } |
| 272 | |
| 273 | return result; |
| 274 | } |
| 275 | |
| 276 | namespace |
| 277 | { |
nothing calls this directly
no test coverage detected