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

Function itkInsertLabel

Modules/Classification/CLUtilities/include/mitkCLUtil.h:459–493  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

457
458 template< typename TImageType >
459 static void itkInsertLabel(TImageType * maskImage, mitk::Image::Pointer & outimage, unsigned int label)
460 {
461
462 typename TImageType::Pointer itk_out;
463
464 if(outimage.IsNull()) // create if necessary
465 {
466 MITK_INFO << "Initialize new image";
467 itk_out = TImageType::New();
468 itk_out->SetSpacing(maskImage->GetSpacing());
469 itk_out->SetDirection(maskImage->GetDirection());
470 itk_out->SetOrigin(maskImage->GetOrigin());
471 itk_out->SetRegions(maskImage->GetLargestPossibleRegion());
472 itk_out->Allocate();
473 itk_out->FillBuffer(0);
474 }else
475 {
476 mitk::CastToItkImage(outimage, itk_out);
477 }
478
479 itk::ImageRegionIterator<TImageType> oit(itk_out,itk_out->GetLargestPossibleRegion());
480 itk::ImageRegionConstIterator<TImageType> mit(maskImage,maskImage->GetLargestPossibleRegion());
481
482 while(!mit.IsAtEnd())
483 {
484 if(mit.Value() != 0)
485 {
486 oit.Set(label);
487 }
488 ++oit;
489 ++mit;
490 }
491
492 mitk::CastToMitkImage(itk_out,outimage);
493 }
494
495
496 template< typename TImageType >

Callers

nothing calls this directly

Calls 10

CastToMitkImageFunction · 0.85
SetDirectionMethod · 0.80
ValueMethod · 0.80
NewFunction · 0.50
IsNullMethod · 0.45
SetSpacingMethod · 0.45
GetSpacingMethod · 0.45
SetOriginMethod · 0.45
GetOriginMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected