I am having some difficulty overlaying boolean masks onto Nifti images. The code below is basically what is shown here (which does work for me when I use the images on the page).
The differences that I can see are that I am using 3 dimensions and Nifti float input rather than 2D images of the same pixel and file types (8-bit PNG) in the example.
Can someone please tell me what I have done wrong? The output image is garbled beyond recognition in ITK Snap
Thanks,
Jared
const unsigned int Dimension = 3;
typedef float PixelType;
typedef unsigned char LabelType;
typedef itk::Image< PixelType, Dimension > ImageVolumeType;
typedef itk::Image< LabelType, Dimension > ContourVolumeType;
typedef itk::ImageFileReader<ContourVolumeType> ContourReaderType;
typedef itk::ImageFileReader< ImageVolumeType > ReaderType;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName( infile1 );
ContourReaderType::Pointer labelReader = ContourReaderType::New();
labelReader->SetFileName(infile2);
typedef itk::LabelObject< LabelType, Dimension > LabelObjectType;
typedef itk::LabelMap< LabelObjectType > LabelMapType;
typedef itk::LabelImageToLabelMapFilter< ContourVolumeType, LabelMapType > ConverterType;
ConverterType::Pointer converter = ConverterType::New();
converter->SetInput( labelReader->GetOutput() );
typedef itk::LabelMapOverlayImageFilter< LabelMapType, ImageVolumeType > FilterType;
FilterType::Pointer filter = FilterType::New();
filter->SetInput( converter->GetOutput() );
filter->SetFeatureImage( reader->GetOutput() );
filter->SetOpacity(0.5);
typedef itk::ImageFileWriter< FilterType::OutputImageType > WriterType;
WriterType::Pointer writer = WriterType::New();
writer->SetFileName(outfile);
writer->SetInput( filter->GetOutput() );
writer->Update();