[ITK-users] Overlay Woes
Becksfort, Jared
Jared.Becksfort at STJUDE.ORG
Thu Jan 25 18:57:04 EST 2018
Hello,
Sorry to send this again, but it had the wrong subject.
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):. https://itk.org/ITKExamples/src/Filtering/ImageFusion/OverlayLabelMapOnTopOfAnImage/Documentation.html
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.
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();
________________________________
Email Disclaimer: www.stjude.org/emaildisclaimer
Consultation Disclaimer: www.stjude.org/consultationdisclaimer
More information about the Insight-users
mailing list