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

Method ConvertImageToGroupImage

Modules/Multilabel/src/mitkLabelSetImageConverter.cpp:241–274  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

239}
240
241mitk::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
276namespace
277{

Callers

nothing calls this directly

Calls 5

NewFunction · 0.50
IsEmptyMethod · 0.45
IsInitializedMethod · 0.45
InitializeMethod · 0.45
GetDimensionMethod · 0.45

Tested by

no test coverage detected